summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/newview/llfloaternotificationstabbed.cpp3
-rw-r--r--indra/newview/llimprocessing.cpp11
-rw-r--r--indra/newview/llnotificationlistitem.cpp31
-rw-r--r--indra/newview/llnotificationlistitem.h1
-rw-r--r--indra/newview/llviewermessage.cpp159
-rw-r--r--indra/newview/llviewermessage.h5
-rw-r--r--indra/newview/llviewerregion.cpp4
7 files changed, 142 insertions, 72 deletions
diff --git a/indra/newview/llfloaternotificationstabbed.cpp b/indra/newview/llfloaternotificationstabbed.cpp
index 4b5fe4989a..d1679fd936 100644
--- a/indra/newview/llfloaternotificationstabbed.cpp
+++ b/indra/newview/llfloaternotificationstabbed.cpp
@@ -387,7 +387,8 @@ void LLFloaterNotificationsTabbed::onStoreToast(LLPanel* info_panel, LLUUID id)
p.notification_name = notify->getName();
p.transaction_id = payload["transaction_id"];
p.group_id = payload["group_id"];
- p.fee = payload["fee"];
+ p.fee = payload["fee"];
+ p.use_offline_cap = payload["use_offline_cap"].asInteger();
p.subject = payload["subject"].asString();
p.message = payload["message"].asString();
p.sender = payload["sender_name"].asString();
diff --git a/indra/newview/llimprocessing.cpp b/indra/newview/llimprocessing.cpp
index 491671c46f..e76b3d118e 100644
--- a/indra/newview/llimprocessing.cpp
+++ b/indra/newview/llimprocessing.cpp
@@ -814,10 +814,11 @@ void LLIMProcessing::processNewMessage(LLUUID from_id,
LLSD payload;
payload["transaction_id"] = session_id;
- payload["group_id"] = from_id;
+ payload["group_id"] = from_group ? from_id : aux_id;
payload["name"] = name;
payload["message"] = message;
payload["fee"] = membership_fee;
+ payload["use_offline_cap"] = session_id.isNull() && (offline == IM_OFFLINE);
LLSD args;
args["MESSAGE"] = message;
@@ -1459,8 +1460,12 @@ void LLIMProcessing::requestOfflineMessages()
// Auto-accepted inventory items may require the avatar object
// to build a correct name. Likewise, inventory offers from
// muted avatars require the mute list to properly mute.
- if (cap_url.empty())
+ if (cap_url.empty()
+ || gAgent.getRegionCapability("AcceptFriendship").empty()
+ || gAgent.getRegionCapability("AcceptGroupInvite").empty())
{
+ // Offline messages capability provides no session/transaction ids for message AcceptFriendship and IM_GROUP_INVITATION to work
+ // So make sure we have the caps before using it.
requestOfflineMessagesLegacy();
}
else
@@ -1561,7 +1566,7 @@ void LLIMProcessing::requestOfflineMessagesCoro(std::string url)
message_data["to_agent_id"].asUUID(),
IM_OFFLINE,
(EInstantMessage)message_data["dialog"].asInteger(),
- LLUUID::null, // session id, fix this for friendship offers to work
+ LLUUID::null, // session id, since there is none we can only use frienship/group invite caps
message_data["timestamp"].asInteger(),
message_data["from_agent_name"].asString(),
message_data["message"].asString(),
diff --git a/indra/newview/llnotificationlistitem.cpp b/indra/newview/llnotificationlistitem.cpp
index f2de8e54a0..a5bc75e6bd 100644
--- a/indra/newview/llnotificationlistitem.cpp
+++ b/indra/newview/llnotificationlistitem.cpp
@@ -312,38 +312,15 @@ void LLGroupInviteNotificationListItem::onClickJoinBtn()
return;
}
- if(mParams.fee > 0)
- {
- LLSD args;
- args["COST"] = llformat("%d", mParams.fee);
- // Set the fee for next time to 0, so that we don't keep
- // asking about a fee.
- LLSD next_payload;
- next_payload["group_id"]= mParams.group_id;
- next_payload["transaction_id"]= mParams.transaction_id;
- next_payload["fee"] = 0;
- LLNotificationsUtil::add("JoinGroupCanAfford", args, next_payload);
- }
- else
- {
- send_improved_im(mParams.group_id,
- std::string("name"),
- std::string("message"),
- IM_ONLINE,
- IM_GROUP_INVITATION_ACCEPT,
- mParams.transaction_id);
- }
+ send_join_group_response(mParams.group_id, mParams.transaction_id, true, mParams.fee, mParams.use_offline_cap);
+
LLNotificationListItem::onClickCloseBtn();
}
void LLGroupInviteNotificationListItem::onClickDeclineBtn()
{
- send_improved_im(mParams.group_id,
- std::string("name"),
- std::string("message"),
- IM_ONLINE,
- IM_GROUP_INVITATION_DECLINE,
- mParams.transaction_id);
+ send_join_group_response(mParams.group_id, mParams.transaction_id, false, mParams.fee, mParams.use_offline_cap);
+
LLNotificationListItem::onClickCloseBtn();
}
diff --git a/indra/newview/llnotificationlistitem.h b/indra/newview/llnotificationlistitem.h
index 3dd52986b0..3d564fed0e 100644
--- a/indra/newview/llnotificationlistitem.h
+++ b/indra/newview/llnotificationlistitem.h
@@ -56,6 +56,7 @@ public:
std::string message;
std::string sender;
S32 fee;
+ U8 use_offline_cap;
LLDate time_stamp;
LLDate received_time;
LLSD inventory_offer;
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index a89b1220de..211d7b8c64 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -198,15 +198,15 @@ void accept_friendship_coro(std::string url, LLSD notification)
void decline_friendship_coro(std::string url, LLSD notification, S32 option)
{
- LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
- LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
- httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("friendshipResponceErrorProcessing", httpPolicy));
- LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
if (url.empty())
{
LL_WARNS() << "Empty capability!" << LL_ENDL;
return;
}
+ LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
+ LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
+ httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("friendshipResponceErrorProcessing", httpPolicy));
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
LLSD payload = notification["payload"];
url += "?from=" + payload["from_id"].asString();
@@ -724,6 +724,119 @@ void send_sound_trigger(const LLUUID& sound_id, F32 gain)
static LLSD sSavedGroupInvite;
static LLSD sSavedResponse;
+void response_group_invitation_coro(std::string url, LLUUID group_id, bool notify_and_update)
+{
+ if (url.empty())
+ {
+ LL_WARNS("GroupInvite") << "Empty capability!" << LL_ENDL;
+ return;
+ }
+
+ LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
+ LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
+ httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("friendshipResponceErrorProcessing", httpPolicy));
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
+
+ LLSD payload;
+ payload["group"] = group_id;
+
+ LLSD result = httpAdapter->postAndSuspend(httpRequest, url, payload);
+
+ LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+
+ if (!status)
+ {
+ LL_WARNS("GroupInvite") << "HTTP status, " << status.toTerseString() <<
+ ". Group " << group_id << " invitation response processing failed." << LL_ENDL;
+ }
+ else
+ {
+ if (!result.has("success") || result["success"].asBoolean() == false)
+ {
+ LL_WARNS("GroupInvite") << "Server failed to process group " << group_id << " invitation response. " << httpResults << LL_ENDL;
+ }
+ else
+ {
+ LL_DEBUGS("GroupInvite") << "Successfully sent response to group " << group_id << " invitation" << LL_ENDL;
+ if (notify_and_update)
+ {
+ LLNotificationsUtil::add("JoinGroupSuccess");
+ gAgent.sendAgentDataUpdateRequest();
+
+ LLGroupMgr::getInstance()->clearGroupData(group_id);
+ // refresh the floater for this group, if any.
+ LLGroupActions::refresh(group_id);
+ }
+ }
+ }
+}
+
+void send_join_group_response(LLUUID group_id, LLUUID transaction_id, bool accept_invite, S32 fee, bool use_offline_cap, LLSD &payload)
+{
+ if (accept_invite && fee > 0)
+ {
+ // If there is a fee to join this group, make
+ // sure the user is sure they want to join.
+ LLSD args;
+ args["COST"] = llformat("%d", fee);
+ // Set the fee for next time to 0, so that we don't keep
+ // asking about a fee.
+ LLSD next_payload = payload;
+ next_payload["fee"] = 0;
+ LLNotificationsUtil::add("JoinGroupCanAfford",
+ args,
+ next_payload);
+ }
+ else if (use_offline_cap)
+ {
+ std::string url;
+ if (accept_invite)
+ {
+ url = gAgent.getRegionCapability("AcceptGroupInvite");
+ }
+ else
+ {
+ url = gAgent.getRegionCapability("DeclineGroupInvite");
+ }
+
+ if (!url.empty())
+ {
+ LLCoros::instance().launch("LLMessageSystem::acceptGroupInvitation",
+ boost::bind(response_group_invitation_coro, url, group_id, accept_invite));
+ }
+ else
+ {
+ // if sim has no this cap, we can do nothing - regular request will fail
+ LL_WARNS("GroupInvite") << "No capability, can't reply to offline invitation!" << LL_ENDL;
+ }
+ }
+ else
+ {
+ EInstantMessage type = accept_invite ? IM_GROUP_INVITATION_ACCEPT : IM_GROUP_INVITATION_DECLINE;
+
+ send_improved_im(group_id,
+ std::string("name"),
+ std::string("message"),
+ IM_ONLINE,
+ type,
+ transaction_id);
+ }
+}
+
+void send_join_group_response(LLUUID group_id, LLUUID transaction_id, bool accept_invite, S32 fee, bool use_offline_cap)
+{
+ LLSD payload;
+ if (accept_invite)
+ {
+ payload["group_id"] = group_id;
+ payload["transaction_id"] = transaction_id;
+ payload["fee"] = fee;
+ payload["use_offline_cap"] = use_offline_cap;
+ }
+ send_join_group_response(group_id, transaction_id, accept_invite, fee, use_offline_cap, payload);
+}
+
bool join_group_response(const LLSD& notification, const LLSD& response)
{
// A bit of variable saving and restoring is used to deal with the case where your group list is full and you
@@ -762,6 +875,7 @@ bool join_group_response(const LLSD& notification, const LLSD& response)
std::string name = notification_adjusted["payload"]["name"].asString();
std::string message = notification_adjusted["payload"]["message"].asString();
S32 fee = notification_adjusted["payload"]["fee"].asInteger();
+ U8 use_offline_cap = notification_adjusted["payload"]["use_offline_cap"].asInteger();
if (option == 2 && !group_id.isNull())
{
@@ -790,42 +904,7 @@ bool join_group_response(const LLSD& notification, const LLSD& response)
return false;
}
}
-
- if (accept_invite)
- {
- // If there is a fee to join this group, make
- // sure the user is sure they want to join.
- if (fee > 0)
- {
- LLSD args;
- args["COST"] = llformat("%d", fee);
- // Set the fee for next time to 0, so that we don't keep
- // asking about a fee.
- LLSD next_payload = notification_adjusted["payload"];
- next_payload["fee"] = 0;
- LLNotificationsUtil::add("JoinGroupCanAfford",
- args,
- next_payload);
- }
- else
- {
- send_improved_im(group_id,
- std::string("name"),
- std::string("message"),
- IM_ONLINE,
- IM_GROUP_INVITATION_ACCEPT,
- transaction_id);
- }
- }
- else
- {
- send_improved_im(group_id,
- std::string("name"),
- std::string("message"),
- IM_ONLINE,
- IM_GROUP_INVITATION_DECLINE,
- transaction_id);
- }
+ send_join_group_response(group_id, transaction_id, accept_invite, fee, use_offline_cap, notification_adjusted["payload"]);
sSavedGroupInvite[id] = LLSD::emptyMap();
sSavedResponse[id] = LLSD::emptyMap();
diff --git a/indra/newview/llviewermessage.h b/indra/newview/llviewermessage.h
index 424aae1229..913abef2be 100644
--- a/indra/newview/llviewermessage.h
+++ b/indra/newview/llviewermessage.h
@@ -66,6 +66,11 @@ enum InventoryOfferResponse
BOOL can_afford_transaction(S32 cost);
void give_money(const LLUUID& uuid, LLViewerRegion* region, S32 amount, BOOL is_group = FALSE,
S32 trx_type = TRANS_GIFT, const std::string& desc = LLStringUtil::null);
+void send_join_group_response(LLUUID group_id,
+ LLUUID transaction_id,
+ bool accept_invite,
+ S32 fee,
+ bool use_offline_cap);
void process_logout_reply(LLMessageSystem* msg, void**);
void process_layer_data(LLMessageSystem *mesgsys, void **user_data);
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 832dcc2dd8..e1437e28f7 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -2818,6 +2818,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames)
{
capabilityNames.append("AbuseCategories");
capabilityNames.append("AcceptFriendship");
+ capabilityNames.append("AcceptGroupInvite"); // ReadOfflineMsgs recieved messages only!!!
capabilityNames.append("AgentPreferences");
capabilityNames.append("AgentState");
capabilityNames.append("AttachmentResources");
@@ -2828,6 +2829,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames)
capabilityNames.append("CopyInventoryFromNotecard");
capabilityNames.append("CreateInventoryCategory");
capabilityNames.append("DeclineFriendship");
+ capabilityNames.append("DeclineGroupInvite"); // ReadOfflineMsgs recieved messages only!!!
capabilityNames.append("DispatchRegionInfo");
capabilityNames.append("DirectDelivery");
capabilityNames.append("EnvironmentSettings");
@@ -2878,7 +2880,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames)
capabilityNames.append("ParcelVoiceInfoRequest");
capabilityNames.append("ProductInfoRequest");
capabilityNames.append("ProvisionVoiceAccountRequest");
- //capabilityNames.append("ReadOfflineMsgs");
+ capabilityNames.append("ReadOfflineMsgs"); // Only use with AcceptGroupInvite AcceptFriendship
capabilityNames.append("RemoteParcelRequest");
capabilityNames.append("RenderMaterials");
capabilityNames.append("RequestTextureDownload");