summaryrefslogtreecommitdiff
path: root/protocols/Discord/src/dispatch.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-01-08 23:27:13 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-01-08 23:27:13 +0300
commit9ab52162d7d1e0bdbf47d412fcfe83d533f0708b (patch)
tree9c8050b008642b41655bd773ca6e516212fba0ae /protocols/Discord/src/dispatch.cpp
parentf05340be7d013ac713fd24c19ff8304712223a73 (diff)
better way of setting avatar either for me or any other user
Diffstat (limited to 'protocols/Discord/src/dispatch.cpp')
-rw-r--r--protocols/Discord/src/dispatch.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp
index e96471f116..0b7f96a33f 100644
--- a/protocols/Discord/src/dispatch.cpp
+++ b/protocols/Discord/src/dispatch.cpp
@@ -36,6 +36,8 @@ static handlers[] = // these structures must me sorted alphabetically
{ L"READY", &CDiscordProto::OnCommandReady },
{ L"TYPING_START", &CDiscordProto::OnCommandTyping },
+
+ { L"USER_UPDATE", &CDiscordProto::OnCommandUserUpdate },
};
static int __cdecl pSearchFunc(const void *p1, const void *p2)
@@ -182,3 +184,32 @@ void CDiscordProto::OnCommandTyping(const JSONNode &pRoot)
debugLogA("user is typing in a group channel, skipped");
}
}
+
+//////////////////////////////////////////////////////////////////////////////////////
+// UTN support
+
+void CDiscordProto::OnCommandUserUpdate(const JSONNode &pRoot)
+{
+ SnowFlake id = _wtoi64(pRoot["id"].as_mstring());
+
+ MCONTACT hContact;
+ if (id != m_ownId) {
+ CDiscordUser *pUser = FindUser(id);
+ if (pUser == NULL)
+ return;
+
+ hContact = pUser->hContact;
+ }
+ else hContact = 0;
+
+ // force rereading avatar
+ ptrW wszOldHash(getWStringA(hContact, DB_KEY_AVHASH));
+ CMStringW wszNewHash(pRoot["avatar"].as_mstring());
+ if (mir_wstrcmp(wszOldHash, wszNewHash)) {
+ setWString(hContact, DB_KEY_AVHASH, wszNewHash);
+
+ PROTO_AVATAR_INFORMATION ai = {};
+ ai.hContact = hContact;
+ GetAvatarInfo(GAIF_FORCE, (LPARAM)&ai);
+ }
+}