diff options
author | George Hazan <george.hazan@gmail.com> | 2024-05-02 21:16:38 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-05-02 21:16:38 +0300 |
commit | 943e68e8a709b7bfa906399ee4641e64f8d51f31 (patch) | |
tree | 0df654d588dda80ff8f3a159964535366144c80b /protocols | |
parent | b9d42763699f1c60f2ea0c3187378df1b2131e75 (diff) |
fixes #4382 (Discord: Groupchat support)
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Discord/src/utils.cpp | 25 |
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;
|