From 0b16ad5c516ef3f32e6d981e0c26369991cefec9 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 7 Aug 2024 19:49:17 +0300 Subject: fixes #4476 (Discord: Not all channels are loaded) --- protocols/Discord/src/guilds.cpp | 7 ++++++- src/mir_app/src/netlib_websocket.cpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/protocols/Discord/src/guilds.cpp b/protocols/Discord/src/guilds.cpp index 4a6df1f34b..59bcdb0649 100644 --- a/protocols/Discord/src/guilds.cpp +++ b/protocols/Discord/src/guilds.cpp @@ -204,7 +204,7 @@ CDiscordUser* CDiscordProto::ProcessGuildChannel(CDiscordGuild *pGuild, const JS bool bIsVoice = false; // filter our all channels but the text ones - switch (pch["type"].as_int()) { + switch (auto iChannelType = pch["type"].as_int()) { case 4: // channel group if (!m_bUseGuildGroups) // ignore groups when they aren't enabled return nullptr; @@ -230,6 +230,7 @@ CDiscordUser* CDiscordProto::ProcessGuildChannel(CDiscordGuild *pGuild, const JS __fallthrough; case 0: // text channel + case 5: // announcement channel // check permissions to enter the channel auto permissions = pGuild->CalcPermissionOverride(m_ownId, pch["permission_overwrites"]); if (!(permissions & Permission::VIEW_CHANNEL)) @@ -247,6 +248,10 @@ CDiscordUser* CDiscordProto::ProcessGuildChannel(CDiscordGuild *pGuild, const JS if (pGuild->arChannels.find(pUser) == nullptr) pGuild->arChannels.insert(pUser); + // make announcement channels read-only + if (iChannelType == 5) + Contact::Readonly(pUser->hContact, true); + pUser->wszUsername = wszChannelId; if (m_bUseGuildGroups) pUser->wszChannelName = L"#" + wszName; diff --git a/src/mir_app/src/netlib_websocket.cpp b/src/mir_app/src/netlib_websocket.cpp index b92d3c168f..05392afe8e 100644 --- a/src/mir_app/src/netlib_websocket.cpp +++ b/src/mir_app/src/netlib_websocket.cpp @@ -305,7 +305,7 @@ void MWebSocket::run() void MJsonWebSocket::process(const uint8_t *buf, size_t cbLen) { CMStringA szJson((char*)buf, (int)cbLen); - Netlib_Logf(m_nlu, "JSON received:\n%s", szJson.c_str()); + Netlib_Log(m_nlu, szJson); JSONNode root = JSONNode::parse(szJson); if (root) -- cgit v1.2.3