From ea69a7bfa94cc8a5d45da23f1a7f1c1beb126d37 Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Fri, 2 Aug 2013 16:49:19 -0400 Subject: [PATCH] Ratany's Feature Request: Add antispam dialog filter bypasses(own objects and friends) and condense antispam dialog blocking into a single function --- indra/newview/app_settings/settings.xml | 22 +++ indra/newview/ascentprefschat.cpp | 8 ++ indra/newview/ascentprefschat.h | 2 + indra/newview/llviewermessage.cpp | 126 +++++++++++------- .../en-us/panel_preferences_ascent_chat.xml | 3 + 5 files changed, 114 insertions(+), 47 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index aa457f772..382fd7955 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -1308,6 +1308,28 @@ This should be as low as possible, but too low may break functionality Value 0 + AntiSpamNotFriends + + Comment + When true, dialogs from friends will not be blocked unless the _NACL_Antispam is true. + Persist + 1 + Type + Boolean + Value + 0 + + AntiSpamNotMine + + Comment + When true, dialogs from your own objects will not be blocked unless the _NACL_Antispam is true. + Persist + 1 + Type + Boolean + Value + 0 + AntiSpamNotify Comment diff --git a/indra/newview/ascentprefschat.cpp b/indra/newview/ascentprefschat.cpp index 8e2df4678..16202e813 100644 --- a/indra/newview/ascentprefschat.cpp +++ b/indra/newview/ascentprefschat.cpp @@ -210,6 +210,10 @@ void LLPrefsAscentChat::onCommitDialogBlock(LLUICtrl* ctrl, const LLSD& value) childSetEnabled("Item Offers", !enabled); childSetEnabled("Scripts", !enabled); childSetEnabled("Teleport Offers", !enabled); + childSetEnabled("Teleport Requests", !enabled); + childSetEnabled("Except those from:", !enabled); + childSetEnabled("My objects", !enabled); + childSetEnabled("My friends", !enabled); } } @@ -329,6 +333,8 @@ void LLPrefsAscentChat::refreshValues() mBlockGroupFeeInviteSpam = gSavedSettings.getBOOL("AntiSpamGroupFeeInvites"); mBlockGroupNoticeSpam = gSavedSettings.getBOOL("AntiSpamGroupNotices"); mBlockItemOfferSpam = gSavedSettings.getBOOL("AntiSpamItemOffers"); + mBlockNotFriendSpam = gSavedSettings.getBOOL("AntiSpamNotFriend"); + mBlockNotMineSpam = gSavedSettings.getBOOL("AntiSpamNotMine"); mBlockScriptSpam = gSavedSettings.getBOOL("AntiSpamScripts"); mBlockTeleportSpam = gSavedSettings.getBOOL("AntiSpamTeleports"); mBlockTeleportRequestSpam = gSavedSettings.getBOOL("AntiSpamTeleportRequests"); @@ -547,6 +553,8 @@ void LLPrefsAscentChat::cancel() gSavedSettings.setBOOL("AntiSpamGroupInvites", mBlockGroupInviteSpam); gSavedSettings.setBOOL("AntiSpamGroupFeeInvites", mBlockGroupFeeInviteSpam); gSavedSettings.setBOOL("AntiSpamItemOffers", mBlockItemOfferSpam); + gSavedSettings.setBOOL("AntiSpamNotFriend", mBlockNotFriendSpam); + gSavedSettings.setBOOL("AntiSpamNotMine", mBlockNotMineSpam); gSavedSettings.setBOOL("AntiSpamScripts", mBlockScriptSpam); gSavedSettings.setBOOL("AntiSpamTeleports", mBlockTeleportSpam); gSavedSettings.setBOOL("AntiSpamTeleportRequests", mBlockTeleportRequestSpam); diff --git a/indra/newview/ascentprefschat.h b/indra/newview/ascentprefschat.h index 476f82551..38fc2d8c8 100644 --- a/indra/newview/ascentprefschat.h +++ b/indra/newview/ascentprefschat.h @@ -105,6 +105,8 @@ protected: BOOL mBlockGroupInviteSpam; BOOL mBlockGroupFeeInviteSpam; BOOL mBlockItemOfferSpam; + bool mBlockNotMineSpam; + bool mBlockNotFriendSpam; BOOL mBlockScriptSpam; BOOL mBlockTeleportSpam; bool mBlockTeleportRequestSpam; diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index d0f57be83..578f23fa6 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -1671,11 +1671,63 @@ bool LLOfferInfo::inventory_offer_callback(const LLSD& notification, const LLSD& return false; } +bool is_spam_filtered(const EInstantMessage& dialog, bool is_friend, bool is_owned_by_me) +{ + // First, check the master filter + static LLCachedControl antispam(gSavedSettings,"_NACL_Antispam"); + if (antispam) return true; + + // Second, check if this dialog type is even being filtered + switch(dialog) + { + case IM_GROUP_NOTICE: + case IM_GROUP_NOTICE_REQUESTED: + if (!gSavedSettings.getBOOL("AntiSpamGroupNotices")) return false; + break; + case IM_GROUP_INVITATION: + if (!gSavedSettings.getBOOL("AntiSpamGroupInvites")) return false; + break; + case IM_INVENTORY_OFFERED: + case IM_TASK_INVENTORY_OFFERED: + if (!gSavedSettings.getBOOL("AntiSpamItemOffers")) return false; + break; + case IM_FROM_TASK_AS_ALERT: + if (!gSavedSettings.getBOOL("AntiSpamAlerts")) return false; + break; + case IM_LURE_USER: + if (!gSavedSettings.getBOOL("AntiSpamTeleports")) return false; + break; + case IM_TELEPORT_REQUEST: + if (!gSavedSettings.getBOOL("AntiSpamTeleportRequests")) return false; + break; + case IM_FRIENDSHIP_OFFERED: + if (!gSavedSettings.getBOOL("AntiSpamFriendshipOffers")) return false; + break; + case IM_COUNT: + // Bit of a hack, we should never get here unless we did this on purpose, though, doesn't matter because we'd do nothing anyway + if (!gSavedSettings.getBOOL("AntiSpamScripts")) return false; + break; + default: + return false; + } + + // Third, possibly filtered, check the filter bypasses + static LLCachedControl antispam_not_mine(gSavedSettings,"AntiSpamNotMine"); + if (antispam_not_mine && is_owned_by_me) + return false; + + static LLCachedControl antispam_not_friends(gSavedSettings,"AntiSpamNotFriends"); + if (antispam_not_friends && is_friend) + return false; + + // Last, definitely filter + return true; +} + void inventory_offer_handler(LLOfferInfo* info) { // NaCl - Antispam Registry - static LLCachedControl antispam(gSavedSettings,"_NACL_Antispam"); - if(antispam || gSavedSettings.getBOOL("AntiSpamItemOffers") || NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_INVENTORY,info->mFromID)) + if (NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_INVENTORY,info->mFromID)) return; // NaCl End //If muted, don't even go through the messaging stuff. Just curtail the offer here. @@ -2071,7 +2123,6 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) { return; } - static LLCachedControl antispam(gSavedSettings,"_NACL_Antispam"); LLUUID from_id; BOOL from_group; LLUUID to_id; @@ -2180,6 +2231,10 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) is_owned_by_me = source->permYouOwner(); } + // NaCl - Antispam + if (is_spam_filtered(dialog, is_friend, is_owned_by_me)) return; + // NaCl End + std::string separator_string(": "); int message_offset = 0; @@ -2545,10 +2600,6 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) case IM_GROUP_NOTICE: case IM_GROUP_NOTICE_REQUESTED: { - // NaCl - Antispam - if(antispam || gSavedSettings.getBOOL("AntiSpamGroupNotices")) - return; - // NaCl End LL_INFOS("Messaging") << "Received IM_GROUP_NOTICE message." << LL_ENDL; // Read the binary bucket for more information. struct notice_bucket_header_t @@ -2664,11 +2715,6 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) break; case IM_GROUP_INVITATION: { - // NaCl - Antispam - if (antispam || gSavedSettings.getBOOL("AntiSpamGroupInvites")) - return; - // NaCl End - //if (!is_linden && (is_busy || is_muted)) if ((is_busy || is_muted)) { @@ -2718,10 +2764,6 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) case IM_TASK_INVENTORY_OFFERED: // Someone has offered us some inventory. { - // NaCl - Antispam - if(antispam || gSavedSettings.getBOOL("AntiSpamItemOffers")) - return; - // NaCl End LLOfferInfo* info = new LLOfferInfo; if (IM_INVENTORY_OFFERED == dialog) { @@ -2990,10 +3032,6 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) } break; case IM_FROM_TASK_AS_ALERT: - // NaCl - Antispam - if(antispam || (!is_owned_by_me && gSavedSettings.getBOOL("AntiSpamAlerts"))) - return; - // NaCl End if (is_busy && !is_owned_by_me) { return; @@ -3022,7 +3060,6 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) case IM_LURE_USER: case IM_TELEPORT_REQUEST: { - if (antispam || gSavedSettings.getBOOL(dialog == IM_LURE_USER ? "AntiSpamTeleports" : "AntiSpamTeleportRequests")) return; //NaCl Antispam // [RLVa:KB] - Checked: 2010-12-11 (RLVa-1.2.2c) | Added: RLVa-1.2.2c // If the lure sender is a specific @accepttp exception they will override muted and busy status bool fRlvSummon = (rlv_handler_t::isEnabled()) && (gRlvHandler.isException(RLV_BHVR_ACCEPTTP, from_id)); @@ -3268,10 +3305,6 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) case IM_FRIENDSHIP_OFFERED: { - // NaCl - Antispam - if(antispam || gSavedSettings.getBOOL("AntiSpamFriendshipOffers")) - return; - // NaCl End LLSD payload; payload["from_id"] = from_id; payload["session_id"] = session_id;; @@ -3424,8 +3457,7 @@ static LLNotificationFunctorRegistration callingcard_offer_cb_reg("OfferCallingC void process_offer_callingcard(LLMessageSystem* msg, void**) { // NaCl - Antispam - static LLCachedControl antispam(gSavedSettings,"_NACL_Antispam"); - if(antispam || gSavedSettings.getBOOL("AntiSpamFriendshipOffers")) + if (is_spam_filtered(IM_FRIENDSHIP_OFFERED, false, false)) return; // NaCl End // someone has offered to form a friendship @@ -6980,11 +7012,6 @@ static LLNotificationFunctorRegistration script_question_cb_reg_2("ScriptQuestio void process_script_question(LLMessageSystem *msg, void **user_data) { - // NaCl - Antispam - static LLCachedControl antispam(gSavedSettings,"_NACL_Antispam"); - if(antispam || gSavedSettings.getBOOL("AntiSpamScripts")) - return; - // NaCl End // *TODO: Translate owner name -> [FIRST] [LAST] LLHost sender = msg->getSender(); @@ -7018,6 +7045,9 @@ void process_script_question(LLMessageSystem *msg, void **user_data) std::string throttle_name = owner_name; std::string self_name; LLAgentUI::buildFullname( self_name ); + // NaCl - Antispam + if (is_spam_filtered(IM_COUNT, false, owner_name == self_name)) return; + // NaCl End if( owner_name == self_name ) { throttle_name = taskid.getString(); @@ -7758,11 +7788,6 @@ static LLNotificationFunctorRegistration callback_script_dialog_reg_2("ScriptDia void process_script_dialog(LLMessageSystem* msg, void**) { - // NaCl - Antispam - static LLCachedControl antispam(gSavedSettings,"_NACL_Antispam"); - if(antispam || gSavedSettings.getBOOL("AntiSpamScripts")) - return; - // NaCl End S32 i; LLSD payload; @@ -7786,6 +7811,10 @@ void process_script_dialog(LLMessageSystem* msg, void**) // NaCl End } + // NaCl - Antispam + if (owner_id.isNull() ? is_spam_filtered(IM_COUNT, LLAvatarActions::isFriend(object_id), object_id == gAgentID) : is_spam_filtered(IM_COUNT, LLAvatarActions::isFriend(owner_id), owner_id == gAgentID)) return; + // NaCl End + if (LLMuteList::getInstance()->isMuted(object_id) || LLMuteList::getInstance()->isMuted(owner_id)) { return; @@ -7934,11 +7963,6 @@ void callback_load_url_name(const LLUUID& id, const std::string& full_name, bool void process_load_url(LLMessageSystem* msg, void**) { - // NaCl - Antispam - static LLCachedControl antispam(gSavedSettings,"_NACL_Antispam"); - if(antispam || gSavedSettings.getBOOL("AntiSpamScripts")) - return; - // NaCl End LLUUID object_id; LLUUID owner_id; BOOL owner_is_group; @@ -7950,6 +7974,10 @@ void process_load_url(LLMessageSystem* msg, void**) msg->getUUID( "Data", "ObjectID", object_id); msg->getUUID( "Data", "OwnerID", owner_id); + // NaCl - Antispam + if (owner_id.isNull() ? is_spam_filtered(IM_COUNT, LLAvatarActions::isFriend(object_id), object_id == gAgentID) : is_spam_filtered(IM_COUNT, LLAvatarActions::isFriend(owner_id), owner_id == gAgentID)) return; + // NaCl End + // NaCl - Antispam Registry if((owner_id.isNull() && NACLAntiSpamRegistry::checkQueue((U32)NACLAntiSpamRegistry::QUEUE_SCRIPT_DIALOG,object_id)) @@ -8029,12 +8057,16 @@ void process_initiate_download(LLMessageSystem* msg, void**) void process_script_teleport_request(LLMessageSystem* msg, void**) { - // NaCl - Antispam - static LLCachedControl antispam(gSavedSettings,"_NACL_Antispam"); - if(antispam || gSavedSettings.getBOOL("AntiSpamScripts")) - return; - // NaCl End if (!gSavedSettings.getBOOL("ScriptsCanShowUI")) return; + // NaCl - Antispam + { + LLUUID object_id, owner_id; + msg->getUUID( "Data", "ObjectID", object_id); + msg->getUUID( "Data", "OwnerID", owner_id); + + if (owner_id.isNull() ? is_spam_filtered(IM_COUNT, LLAvatarActions::isFriend(object_id), object_id == gAgentID) : is_spam_filtered(IM_COUNT, LLAvatarActions::isFriend(owner_id), owner_id == gAgentID)) return; + } + // NaCl End std::string object_name; std::string sim_name; diff --git a/indra/newview/skins/default/xui/en-us/panel_preferences_ascent_chat.xml b/indra/newview/skins/default/xui/en-us/panel_preferences_ascent_chat.xml index 8d98b9fec..00be0ba68 100644 --- a/indra/newview/skins/default/xui/en-us/panel_preferences_ascent_chat.xml +++ b/indra/newview/skins/default/xui/en-us/panel_preferences_ascent_chat.xml @@ -112,6 +112,9 @@ The following wildcards are available to enhance your autoresponses: #n for user + Except those from: + +