summaryrefslogtreecommitdiff
path: root/protocols/Discord/src/server.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-01-08 22:47:46 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-01-08 22:47:46 +0300
commitf05340be7d013ac713fd24c19ff8304712223a73 (patch)
tree93e3ba9441fb0f90a237011778038771e6ccb052 /protocols/Discord/src/server.cpp
parent92f80d349f63f694d0fdcf003a852fd424557663 (diff)
avatar support for Discord
Diffstat (limited to 'protocols/Discord/src/server.cpp')
-rw-r--r--protocols/Discord/src/server.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp
index c2c539f4d9..9164107309 100644
--- a/protocols/Discord/src/server.cpp
+++ b/protocols/Discord/src/server.cpp
@@ -110,17 +110,28 @@ void CDiscordProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpReques
return;
}
+ ptrW wszOldAvatar(getWStringA(hContact, DB_KEY_AVHASH));
+
m_ownId = _wtoi64(root["id"].as_mstring());
setId(hContact, DB_KEY_ID, m_ownId);
setByte(hContact, DB_KEY_MFA, root["mfa_enabled"].as_bool());
setDword(hContact, DB_KEY_DISCR, root["discriminator"].as_int());
setWString(hContact, DB_KEY_NICK, root["username"].as_mstring());
- setWString(hContact, DB_KEY_AVHASH, root["avatar"].as_mstring());
setWString(hContact, DB_KEY_EMAIL, root["email"].as_mstring());
- if (hContact == NULL)
+ CMStringW wszNewAvatar(root["avatar"].as_mstring());
+ setWString(hContact, DB_KEY_AVHASH, wszNewAvatar);
+
+ if (hContact == NULL) {
+ // if avatar's hash changed, we need to request a new one
+ if (mir_wstrcmp(wszNewAvatar, wszOldAvatar)) {
+ PROTO_AVATAR_INFORMATION ai = {};
+ GetAvatarInfo(GAIF_FORCE, (LPARAM)&ai);
+ }
+
OnLoggedIn();
+ }
}
/////////////////////////////////////////////////////////////////////////////////////////