summaryrefslogtreecommitdiff
path: root/indra/newview/llviewermessage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewermessage.cpp')
-rw-r--r--indra/newview/llviewermessage.cpp159
1 files changed, 119 insertions, 40 deletions
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();