From 1e1ea00373b2f0d64cfa9f447a31ec0cb83ddd73 Mon Sep 17 00:00:00 2001 From: Zi Ree Date: Tue, 30 Dec 2025 11:38:13 +0100 Subject: [PATCH] Omnifilter: actually show the replacement for agents but add the Omnifilter Replacement tag to it. --- indra/newview/llimprocessing.cpp | 9 +-------- indra/newview/llimview.cpp | 19 +++++++++++++++---- indra/newview/llviewermessage.cpp | 5 +---- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/indra/newview/llimprocessing.cpp b/indra/newview/llimprocessing.cpp index a5809864bd..0eeb264de0 100644 --- a/indra/newview/llimprocessing.cpp +++ b/indra/newview/llimprocessing.cpp @@ -731,14 +731,11 @@ void LLIMProcessing::processNewMessage(LLUUID from_id, haystack.mSenderName = agentName; haystack.mOwnerID = from_id; - bool forbid_chat_replacement = false; - switch (dialog) { case IM_NOTHING_SPECIAL: // this is the type for regular IMs { haystack.mType = OmnifilterEngine::eType::InstantMessage; - forbid_chat_replacement = true; break; } case IM_SESSION_SEND: // this is the type for regular group IMs @@ -746,7 +743,6 @@ void LLIMProcessing::processNewMessage(LLUUID from_id, case IM_DO_NOT_DISTURB_AUTO_RESPONSE: { haystack.mType = OmnifilterEngine::eType::GroupChat; - forbid_chat_replacement = true; break; } case IM_FROM_TASK: @@ -814,10 +810,7 @@ void LLIMProcessing::processNewMessage(LLUUID from_id, const OmnifilterEngine::Needle* needle = OmnifilterEngine::getInstance()->match(haystack); if (needle) { - if ( - forbid_chat_replacement // no text replacement for agent messages to prevent forgery attempts - || needle->mChatReplace.empty() // no replacement defined, just suppress the message - ) + if (needle->mChatReplace.empty()) // no replacement defined, just suppress the message { return; } diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index f263c38f69..19a5d085c0 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -3462,7 +3462,10 @@ void LLIMMgr::addMessage( const LLUUID& session_id, const LLUUID& target_id, const std::string& from, - const std::string& msg, + // Omnifilter support + // const std::string& msg, + const std::string& original_msg, + // bool is_offline_msg, const std::string& session_name, EInstantMessage dialog, @@ -3477,6 +3480,8 @@ void LLIMMgr::addMessage( bool keyword_alert_performed) // Pass info if keyword alert has been performed { // Omnifilter support + std::string msg = original_msg; + static LLCachedControl use_omnifilter(gSavedSettings, "OmnifilterEnabled"); if (use_omnifilter) { @@ -3485,7 +3490,7 @@ void LLIMMgr::addMessage( if (dialog == IM_SESSION_INVITE) { OmnifilterEngine::Haystack haystack; - haystack.mContent = msg; + haystack.mContent = original_msg; haystack.mSenderName = from; haystack.mOwnerID = target_id; haystack.mType = OmnifilterEngine::eType::GroupChat; @@ -3493,8 +3498,14 @@ void LLIMMgr::addMessage( const OmnifilterEngine::Needle* needle = OmnifilterEngine::getInstance()->match(haystack); if (needle) { - // no text replacement for agent messages to prevent forgery attempts - return; + if (needle->mChatReplace.empty()) // no replacement defined, just suppress the message + { + return; + } + + LLSD args; + args["REPLACEMENT"] = needle->mChatReplace; + msg = LLTrans::getString("OmnifilterReplacement", args); } } } diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 46ebe6f568..3b601c20b4 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -3300,10 +3300,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data) ((LLVOAvatar*)chatter)->stopTyping(); } - if ( - chat.mSourceType == CHAT_SOURCE_AGENT // no text replacement for agent chat to prevent forgery attempts - || needle->mChatReplace.empty() // no replacement defined, just suppress the message - ) + if (needle->mChatReplace.empty()) // no replacement defined, just suppress the message { return; }