summaryrefslogtreecommitdiff
path: root/protocols/Discord/src/guilds.cpp
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 /protocols/Discord/src/guilds.cpp
parent38656ac8639e13836567256651421a1758262e91 (diff)
fixes #2969 (Discord: display users nicks instead of Discord tag in MUC)
Diffstat (limited to 'protocols/Discord/src/guilds.cpp')
-rw-r--r--protocols/Discord/src/guilds.cpp14
1 files changed, 10 insertions, 4 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;