diff options
author | Rider Linden <rider@lindenlab.com> | 2024-10-23 13:51:52 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-23 13:51:52 -0700 |
commit | 4cc997bcae52f07857b16043b78d6bb8ef695398 (patch) | |
tree | d9e19ab5ca9baa506e2b2646c3fb516af4e61452 /indra/newview/llimprocessing.cpp | |
parent | 7783191f91b19d10a14cdb475fedad46ddaa8a9b (diff) | |
parent | 1f4b1dc174625d32bfdbd0e93847bd478f06f47f (diff) |
Merge pull request #2908 from secondlife/rider/chat_metadata
Bot self identification.
Diffstat (limited to 'indra/newview/llimprocessing.cpp')
-rw-r--r-- | indra/newview/llimprocessing.cpp | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/indra/newview/llimprocessing.cpp b/indra/newview/llimprocessing.cpp index 590cd09a31..f5b149335b 100644 --- a/indra/newview/llimprocessing.cpp +++ b/indra/newview/llimprocessing.cpp @@ -422,6 +422,7 @@ void LLIMProcessing::processNewMessage(LLUUID from_id, U8 *binary_bucket, S32 binary_bucket_size, LLHost &sender, + LLSD metadata, LLUUID aux_id) { LLChat chat; @@ -451,6 +452,28 @@ void LLIMProcessing::processNewMessage(LLUUID from_id, bool is_linden = chat.mSourceType != CHAT_SOURCE_OBJECT && LLMuteList::isLinden(name); + /*** + * The simulator may have flagged this sender as a bot, if the viewer would like to display + * the chat text in a different color or font, the below code is how the viewer can + * tell if the sender is a bot. + *----------------------------------------------------- + bool is_bot = false; + if (metadata.has("sender")) + { // The server has identified this sender as a bot. + is_bot = metadata["sender"]["bot"].asBoolean(); + } + *----------------------------------------------------- + */ + + std::string notice_name; + LLSD notice_args; + if (metadata.has("notice")) + { // The server has injected a notice into the IM conversation. + // These will be things like bot notifications, etc. + notice_name = metadata["notice"]["id"].asString(); + notice_args = metadata["notice"]["data"]; + } + chat.mMuted = is_muted; chat.mFromID = from_id; chat.mFromName = name; @@ -544,7 +567,7 @@ void LLIMProcessing::processNewMessage(LLUUID from_id, } else { - // standard message, not from system + // standard message, server may have injected a notice into the conversation. std::string saved; if (offline == IM_OFFLINE) { @@ -579,8 +602,16 @@ void LLIMProcessing::processNewMessage(LLUUID from_id, region_message = true; } } - gIMMgr->addMessage( - session_id, + + if (!notice_name.empty()) + { // The simulator has injected some sort of notice into the conversation. + // findString will only replace the contents of buffer if the notice_id is found. + LLTrans::findString(buffer, notice_name, notice_args); + name = SYSTEM_FROM; + from_id = LLUUID::null; + } + + gIMMgr->addMessage(session_id, from_id, name, buffer, @@ -592,6 +623,7 @@ void LLIMProcessing::processNewMessage(LLUUID from_id, position, region_message, timestamp); + } else { @@ -1627,6 +1659,12 @@ void LLIMProcessing::requestOfflineMessagesCoro(std::string url) from_group = message_data["from_group"].asString() == "Y"; } + LLSD metadata; + if (message_data.has("metadata")) + { + metadata = message_data["metadata"]; + } + EInstantMessage dialog = static_cast<EInstantMessage>(message_data["dialog"].asInteger()); LLUUID session_id = message_data["transaction-id"].asUUID(); if (session_id.isNull() && dialog == IM_FROM_TASK) @@ -1654,6 +1692,7 @@ void LLIMProcessing::requestOfflineMessagesCoro(std::string url) local_bin_bucket.data(), S32(local_bin_bucket.size()), local_sender, + metadata, message_data["asset_id"].asUUID()); }); |