From 2dd79d28dbb40fe1b9d78ea5f5490bab1bb2ed5e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 7 Aug 2024 19:21:47 +0300 Subject: for #4505 - Miranda not to create chat rooms for channels in the banned guilds --- protocols/Discord/src/dispatch.cpp | 8 +++----- protocols/Discord/src/guilds.cpp | 10 +++++++--- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'protocols/Discord/src') diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp index ac2c886857..abcae9afb8 100644 --- a/protocols/Discord/src/dispatch.cpp +++ b/protocols/Discord/src/dispatch.cpp @@ -265,8 +265,7 @@ void CDiscordProto::OnCommandFriendRemoved(const JSONNode &pRoot) void CDiscordProto::OnCommandGuildCreated(const JSONNode &pRoot) { - if (m_bUseGroupchats) - ProcessGuild(pRoot); + ProcessGuild(pRoot); } void CDiscordProto::OnCommandGuildDeleted(const JSONNode &pRoot) @@ -623,9 +622,8 @@ void CDiscordProto::OnCommandReady(const JSONNode &pRoot) m_szGatewaySessionId = pRoot["session_id"].as_mstring(); - if (m_bUseGroupchats) - for (auto &it : pRoot["guilds"]) - ProcessGuild(it); + for (auto &it : pRoot["guilds"]) + ProcessGuild(it); for (auto &it : pRoot["relationships"]) { CDiscordUser *pUser = PrepareUser(it["user"]); diff --git a/protocols/Discord/src/guilds.cpp b/protocols/Discord/src/guilds.cpp index b4e25ebe1f..4a6df1f34b 100644 --- a/protocols/Discord/src/guilds.cpp +++ b/protocols/Discord/src/guilds.cpp @@ -121,6 +121,9 @@ void CDiscordProto::CreateChat(CDiscordGuild *pGuild, CDiscordUser *pUser) void CDiscordProto::ProcessGuild(const JSONNode &pRoot) { + if (!m_bUseGroupchats) + return; + SnowFlake guildId = ::getId(pRoot["id"]); CDiscordGuild *pGuild = FindGuild(guildId); @@ -146,13 +149,14 @@ void CDiscordProto::ProcessGuild(const JSONNode &pRoot) Chat_Control(si, WINDOW_HIDDEN); Chat_Control(si, SESSION_ONLINE); - + for (auto &it : pRoot["roles"]) pGuild->ProcessRole(it); BuildStatusList(pGuild, si); - if (!pGuild->m_bSynced && getByte(si->hContact, DB_KEY_ENABLE_SYNC)) + bool bEnableSync = getByte(si->hContact, DB_KEY_ENABLE_SYNC); + if (!pGuild->m_bSynced && bEnableSync) GatewaySendGuildInfo(pGuild); // store all guild members @@ -183,7 +187,7 @@ void CDiscordProto::ProcessGuild(const JSONNode &pRoot) for (auto &it : pGuild->arChatUsers) AddGuildUser(pGuild, *it); - if (!m_bTerminated) + if (!m_bTerminated && bEnableSync) ForkThread(&CDiscordProto::BatchChatCreate, pGuild); pGuild->m_bSynced = true; -- cgit v1.2.3