Omnifilter: actually show the replacement for agents but add the Omnifilter Replacement tag to it.

meow-7.2.2
Zi Ree 2025-12-30 11:38:13 +01:00
parent d77a846c34
commit 1e1ea00373
3 changed files with 17 additions and 16 deletions

View File

@ -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;
}

View File

@ -3462,7 +3462,10 @@ void LLIMMgr::addMessage(
const LLUUID& session_id,
const LLUUID& target_id,
const std::string& from,
const std::string& msg,
// </FS:Zi> Omnifilter support
// const std::string& msg,
const std::string& original_msg,
// </FS:Zi>
bool is_offline_msg,
const std::string& session_name,
EInstantMessage dialog,
@ -3477,6 +3480,8 @@ void LLIMMgr::addMessage(
bool keyword_alert_performed) // <FS:Ansariel> Pass info if keyword alert has been performed
{
// <FS:Zi> Omnifilter support
std::string msg = original_msg;
static LLCachedControl<bool> 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);
}
}
}

View File

@ -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;
}