From f05340be7d013ac713fd24c19ff8304712223a73 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 8 Jan 2017 22:47:46 +0300 Subject: avatar support for Discord --- protocols/Discord/src/server.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'protocols/Discord/src/server.cpp') 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(); + } } ///////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3