summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/Discord/src/utils.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/protocols/Discord/src/utils.cpp b/protocols/Discord/src/utils.cpp
index b703fc63bb..42fd0bd4d9 100644
--- a/protocols/Discord/src/utils.cpp
+++ b/protocols/Discord/src/utils.cpp
@@ -187,8 +187,23 @@ void CDiscordProto::PreparePrivateChannel(const JSONNode &root)
pUser->bIsGroup = true;
pUser->wszUsername = wszChannelId;
pUser->wszChannelName = root["name"].as_mstring();
+ if (pUser->wszChannelName.IsEmpty()) {
+ int i = 0;
+ for (auto &it : root["recipients"]) {
+ CMStringW wszNick = it["username"].as_mstring();
+ if (wszNick.IsEmpty())
+ continue;
+
+ if (!pUser->wszChannelName.IsEmpty())
+ pUser->wszChannelName += L", ";
+ pUser->wszChannelName += wszNick;
+
+ if (i++ > 3)
+ break;
+ }
+ }
{
- SESSION_INFO *si = Chat_NewSession(GCW_CHATROOM, m_szModuleName, pUser->wszUsername, pUser->wszChannelName);
+ SESSION_INFO *si = pUser->si = Chat_NewSession(GCW_CHATROOM, m_szModuleName, pUser->wszUsername, pUser->wszChannelName);
pUser->hContact = si->hContact;
Chat_AddGroup(si, LPGENW("Owners"));
@@ -196,12 +211,12 @@ void CDiscordProto::PreparePrivateChannel(const JSONNode &root)
SnowFlake ownerId = _wtoi64(root["owner_id"].as_mstring());
- GCEVENT gce = { pUser->si, GC_EVENT_JOIN };
+ GCEVENT gce = { si, GC_EVENT_JOIN };
for (auto &it : root["recipients"]) {
CMStringW wszId = it["id"].as_mstring();
CMStringW wszNick = it["nick"].as_mstring();
if (wszNick.IsEmpty())
- wszNick = it["username"].as_mstring() + L"#" + it["discriminator"].as_mstring();
+ wszNick = getNick(it);
gce.pszUID.w = wszId;
gce.pszNick.w = wszNick;
@@ -217,8 +232,8 @@ void CDiscordProto::PreparePrivateChannel(const JSONNode &root)
gce.pszStatus.w = (_wtoi64(wszId) == ownerId) ? L"Owners" : L"Participants";
Chat_Event(&gce);
- Chat_Control(pUser->si, m_bHideGroupchats ? WINDOW_HIDDEN : SESSION_INITDONE);
- Chat_Control(pUser->si, SESSION_ONLINE);
+ Chat_Control(si, m_bHideGroupchats ? WINDOW_HIDDEN : SESSION_INITDONE);
+ Chat_Control(si, SESSION_ONLINE);
}
break;