diff options
author | George Hazan <ghazan@miranda.im> | 2017-01-23 18:34:15 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-01-23 18:34:15 +0300 |
commit | ac6a2d3c5a668324d4115305a621a81e4b5d99fb (patch) | |
tree | b650b4c84c1f7b26d1ca8b1d58776fd65870eec9 /protocols/Discord/src/dispatch.cpp | |
parent | 705649686832a6e12d7eea59e20528a7e61abe14 (diff) |
automatic channel creation if user has none
Diffstat (limited to 'protocols/Discord/src/dispatch.cpp')
-rw-r--r-- | protocols/Discord/src/dispatch.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp index 102a933aa4..3afa2f7a1c 100644 --- a/protocols/Discord/src/dispatch.cpp +++ b/protocols/Discord/src/dispatch.cpp @@ -64,8 +64,10 @@ GatewayHandlerFunc CDiscordProto::GetHandler(const wchar_t *pwszCommand) void CDiscordProto::OnCommandChannelCreated(const JSONNode &pRoot) { - CDiscordUser *pUser = PrepareUser(pRoot["user"]); - if (pUser != NULL) { + const JSONNode &members = pRoot["recipients"]; + for (auto it = members.begin(); it != members.end(); ++it) { + CDiscordUser *pUser = PrepareUser(*it); + pUser->lastMessageId = _wtoi64(pRoot["last_message_id"].as_mstring()); pUser->channelId = _wtoi64(pRoot["id"].as_mstring()); setId(pUser->hContact, DB_KEY_CHANNELID, pUser->channelId); } @@ -73,9 +75,9 @@ void CDiscordProto::OnCommandChannelCreated(const JSONNode &pRoot) void CDiscordProto::OnCommandChannelDeleted(const JSONNode &pRoot) { - CDiscordUser *pUser = FindUserByChannel(pRoot["channel_id"]); + CDiscordUser *pUser = FindUserByChannel(_wtoi64(pRoot["id"].as_mstring())); if (pUser != NULL) { - pUser->channelId = 0; + pUser->channelId = pUser->lastMessageId = 0; delSetting(pUser->hContact, DB_KEY_CHANNELID); } } |