From a01747f4463feb7fbbbc2f0564d7906cea86cd24 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Sun, 26 Jul 2020 21:16:58 +0200 Subject: [PATCH] FIRE-24171: Ignore group chats on startup until mute list is loaded to prevent showing unwanted group chats --- indra/newview/exogroupmutelist.cpp | 56 ++++++++++++++++++++++++++++-- indra/newview/exogroupmutelist.h | 7 ++-- indra/newview/llimprocessing.cpp | 5 +-- indra/newview/llimview.cpp | 19 +++++----- 4 files changed, 73 insertions(+), 14 deletions(-) diff --git a/indra/newview/exogroupmutelist.cpp b/indra/newview/exogroupmutelist.cpp index 460db2d799..744ff9de78 100644 --- a/indra/newview/exogroupmutelist.cpp +++ b/indra/newview/exogroupmutelist.cpp @@ -29,6 +29,9 @@ // Server-side storage #include "llmutelist.h" #include "llviewernetwork.h" +#include "llimview.h" +#include "llagent.h" +#include "llviewercontrol.h" exoGroupMuteList::exoGroupMuteList() : mMuted() @@ -57,6 +60,17 @@ bool exoGroupMuteList::isMuted(const LLUUID& group) const // Server-side storage } +bool exoGroupMuteList::isLoaded() const +{ +#ifdef OPENSIM + if (LLGridManager::instance().isInOpenSim()) + { + return true; + } +#endif + return LLMuteList::instance().isLoaded(); +} + void exoGroupMuteList::add(const LLUUID& group) { LLGroupActions::endIM(group); // Actually kill ongoing conversation @@ -150,9 +164,47 @@ std::string exoGroupMuteList::getFilePath() const return gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "muted_groups.xml"); } -// Server-side storage + +void exoGroupMuteList::addDeferredGroupChat(const LLUUID& group) +{ + if (mDeferredGroupChatSessionIDs.find(group) == mDeferredGroupChatSessionIDs.end()) + { + mDeferredGroupChatSessionIDs.insert(group); + } +} + +bool exoGroupMuteList::restoreDeferredGroupChat(const LLUUID& group) +{ + if (!isLoaded()) + { + return false; + } + + auto groupIt = mDeferredGroupChatSessionIDs.find(group); + if (groupIt != mDeferredGroupChatSessionIDs.end()) + { + mDeferredGroupChatSessionIDs.erase(groupIt); + + LLGroupData groupData; + if (gAgent.getGroupData(group, groupData)) + { + gIMMgr->addSession(groupData.mName, IM_SESSION_INVITE, group); + + uuid_vec_t ids; + LLIMModel::sendStartSession(group, group, ids, IM_SESSION_GROUP_START); + + if (!gAgent.isDoNotDisturb() && gSavedSettings.getU32("PlayModeUISndNewIncomingGroupIMSession") != 0) + { + make_ui_sound("UISndNewIncomingGroupIMSession"); + } + return true; + } + } + + return false; +} + std::string exoGroupMuteList::getMutelistString(const LLUUID& group) const { return std::string("Group:" + group.asString()); } -// Server-side storage diff --git a/indra/newview/exogroupmutelist.h b/indra/newview/exogroupmutelist.h index efd2b4b79f..a1c7d74eb4 100644 --- a/indra/newview/exogroupmutelist.h +++ b/indra/newview/exogroupmutelist.h @@ -28,17 +28,20 @@ class exoGroupMuteList : public LLSingleton public: bool isMuted(const LLUUID &group) const; + bool isLoaded() const; void add(const LLUUID &group); void remove(const LLUUID &group); bool loadMuteList(); + void addDeferredGroupChat(const LLUUID& group); + bool restoreDeferredGroupChat(const LLUUID& group); private: bool saveMuteList(); std::string getFilePath() const; - std::set mMuted; + uuid_set_t mMuted; + uuid_set_t mDeferredGroupChatSessionIDs; - // Server-side storage std::string getMutelistString(const LLUUID& group) const; }; diff --git a/indra/newview/llimprocessing.cpp b/indra/newview/llimprocessing.cpp index 9585452fc1..57c5ea688f 100644 --- a/indra/newview/llimprocessing.cpp +++ b/indra/newview/llimprocessing.cpp @@ -69,6 +69,7 @@ // [/RLVa:KB] // Firestorm includes +#include "exogroupmutelist.h" #include "fscommon.h" #include "fsdata.h" #include "fskeywords.h" @@ -1621,8 +1622,8 @@ void LLIMProcessing::processNewMessage(LLUUID from_id, // should happen after you get an "invitation" // [SL:KB] - Patch: Chat-GroupSnooze | Checked: 2012-06-16 (Catznip-3.3) //if ( !gIMMgr->hasSession(session_id) ) - if ( (!gIMMgr->hasSession(session_id)) && - ( (!gAgent.isInGroup(session_id)) || (!gIMMgr->checkSnoozeExpiration(session_id)) || LLAvatarActions::isBlocked(from_id) || (!gIMMgr->restoreSnoozedSession(session_id)) ) ) + if (!gIMMgr->hasSession(session_id) && + (!gAgent.isInGroup(session_id) || LLAvatarActions::isBlocked(from_id) || (!exoGroupMuteList::instance().restoreDeferredGroupChat(session_id) && (!gIMMgr->checkSnoozeExpiration(session_id) || !gIMMgr->restoreSnoozedSession(session_id)) ))) // [/SL:KB] { return; diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index b1d50d0c53..2bd2569760 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -2991,9 +2991,9 @@ void LLIMMgr::addMessage( static LLCachedControl PlayModeUISndNewIncomingIMSession(gSavedSettings, "PlayModeUISndNewIncomingIMSession"); static LLCachedControl PlayModeUISndNewIncomingGroupIMSession(gSavedSettings, "PlayModeUISndNewIncomingGroupIMSession"); static LLCachedControl PlayModeUISndNewIncomingConfIMSession(gSavedSettings, "PlayModeUISndNewIncomingConfIMSession"); - BOOL do_not_disturb = gAgent.isDoNotDisturb(); - BOOL is_group_chat = FALSE; - if (!new_session && dialog != IM_NOTHING_SPECIAL) + bool do_not_disturb = gAgent.isDoNotDisturb(); + bool is_group_chat = false; + if (dialog != IM_NOTHING_SPECIAL) { is_group_chat = gAgent.isInGroup(new_session_id); } @@ -3010,6 +3010,13 @@ void LLIMMgr::addMessage( // Clear muted group chat early to prevent contacts floater // (re-)gaining focus; the server already knows the correct // session id, so we can leave it! + if (is_group_chat && !exoGroupMuteList::instance().isLoaded()) + { + LL_INFOS() << "Received group chat from " << fixed_session_name << " (" << new_session_id.asString() << ") before must list has been loaded - skipping message" << LL_ENDL; + exoGroupMuteList::instance().addDeferredGroupChat(new_session_id); + return; + } + if (exoGroupMuteList::instance().isMuted(new_session_id)) { LL_INFOS() << "Muting group chat from " << new_session_id.asString() << ": " << fixed_session_name << LL_ENDL; @@ -3033,6 +3040,7 @@ void LLIMMgr::addMessage( gAgent.isInGroup(new_session_id) && LLMuteList::getInstance()->isMuted(other_participant_id) && !from_linden) { LL_INFOS() << "Ignoring group chat initiated by muted resident." << LL_ENDL; + exoGroupMuteList::instance().addDeferredGroupChat(new_session_id); return; } // @@ -3084,11 +3092,6 @@ void LLIMMgr::addMessage( // //Play sound for new conversations // if (!gAgent.isDoNotDisturb() && (gSavedSettings.getBOOL("PlaySoundNewConversation") == TRUE)) - if (dialog != IM_NOTHING_SPECIAL) - { - is_group_chat = gAgent.isInGroup(new_session_id); - } - // Option to automatically ignore and leave all conference (ad-hoc) chats static LLCachedControl ignoreAdHocSessions(gSavedSettings, "FSIgnoreAdHocSessions"); if (dialog != IM_NOTHING_SPECIAL && !is_group_chat && ignoreAdHocSessions && !from_linden)