summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-11-18 20:52:06 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-11-18 20:52:06 +0300
commit2ff4116cc11b7b3678f191de0dfb596029add833 (patch)
treedbeafd6ef54f6e084e6815ba1ad2210488c1e787
parent38656ac8639e13836567256651421a1758262e91 (diff)
fixes #2969 (Discord: display users nicks instead of Discord tag in MUC)
-rw-r--r--protocols/Discord/src/guilds.cpp14
-rw-r--r--protocols/Discord/src/version.h2
2 files changed, 11 insertions, 5 deletions
diff --git a/protocols/Discord/src/guilds.cpp b/protocols/Discord/src/guilds.cpp
index 7178fe7203..267084b60a 100644
--- a/protocols/Discord/src/guilds.cpp
+++ b/protocols/Discord/src/guilds.cpp
@@ -278,10 +278,12 @@ CDiscordUser* CDiscordProto::ProcessGuildChannel(CDiscordGuild *pGuild, const JS
/////////////////////////////////////////////////////////////////////////////////////////
-CDiscordGuildMember* CDiscordProto::ProcessGuildUser(CDiscordGuild *pGuild, const JSONNode &pUser, bool *pbNew)
+CDiscordGuildMember* CDiscordProto::ProcessGuildUser(CDiscordGuild *pGuild, const JSONNode &pRoot, bool *pbNew)
{
+ auto& pUser = pRoot["user"];
+
bool bNew = false;
- CMStringW wszUserId = pUser["user"]["id"].as_mstring();
+ CMStringW wszUserId = pUser["id"].as_mstring();
SnowFlake userId = _wtoi64(wszUserId);
CDiscordGuildMember *pm = pGuild->FindUser(userId);
if (pm == nullptr) {
@@ -290,13 +292,17 @@ CDiscordGuildMember* CDiscordProto::ProcessGuildUser(CDiscordGuild *pGuild, cons
bNew = true;
}
- pm->wszNick = pUser["user"]["username"].as_mstring() + L"#" + pUser["user"]["discriminator"].as_mstring();
+ pm->wszNick = pRoot["nick"].as_mstring();
+ if (pm->wszNick.IsEmpty())
+ pm->wszNick = pUser["username"].as_mstring() + L"#" + pUser["discriminator"].as_mstring();
+ else
+ bNew = true;
if (userId == pGuild->ownerId)
pm->wszRole = L"@owner";
else {
CDiscordRole *pRole = nullptr;
- for (auto &itr : pUser["roles"]) {
+ for (auto &itr : pRoot["roles"]) {
SnowFlake roleId = ::getId(itr);
if (pRole = pGuild->arRoles.find((CDiscordRole *)&roleId))
break;
diff --git a/protocols/Discord/src/version.h b/protocols/Discord/src/version.h
index f251323329..d054be3648 100644
--- a/protocols/Discord/src/version.h
+++ b/protocols/Discord/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 6
#define __RELEASE_NUM 2
-#define __BUILD_NUM 10
+#define __BUILD_NUM 11
#include <stdver.h>