summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-08-07 19:21:47 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-08-07 19:21:47 +0300
commit2dd79d28dbb40fe1b9d78ea5f5490bab1bb2ed5e (patch)
treebf125310e280181dc263f33b5a2885e1858da7a7
parent5732a19c7dd15ee2a70fb30b3b27db9514208d2f (diff)
for #4505 - Miranda not to create chat rooms for channels in the banned guilds
-rw-r--r--protocols/Discord/src/dispatch.cpp8
-rw-r--r--protocols/Discord/src/guilds.cpp10
2 files changed, 10 insertions, 8 deletions
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;