diff options
author | George Hazan <ghazan@miranda.im> | 2023-01-10 20:14:41 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-01-10 20:14:41 +0300 |
commit | 605743d6e763b3aa2868133f50f99f15293a9a29 (patch) | |
tree | 415b27490160a9dd0ec3f5f4a085bf07ec5c5f34 /protocols/Telegram/src/server.cpp | |
parent | 83278f1c0a1b12b349617b7ebc5583be17e69daa (diff) |
Telegram: support for avatars
Diffstat (limited to 'protocols/Telegram/src/server.cpp')
-rw-r--r-- | protocols/Telegram/src/server.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index c3c54b3065..fbb6c53f3d 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -124,6 +124,10 @@ void CMTProto::ProcessResponse(td::ClientManager::Response response) ProcessMarkRead((TD::updateChatReadInbox *)response.object.get()); break; + case TD::updateFile::ID: + ProcessFile((TD::updateFile*)response.object.get()); + break; + case TD::updateNewChat::ID: ProcessChat((TD::updateNewChat *)response.object.get()); break; @@ -379,6 +383,21 @@ void CMTProto::ProcessUser(TD::updateUser *pObj) else ExtraIcon_SetIconByName(g_plugin.m_hIcon, pu->hContact, nullptr); + if (auto *pPhoto = pUser->profile_photo_.get()) { + if (auto *pSmall = pPhoto->small_.get()) { + auto remoteId = pSmall->remote_->unique_id_; + auto storedId = getMStringA(pu->hContact, DBKEY_AVATAR_HASH); + if (remoteId != storedId.c_str()) { + if (!remoteId.empty()) { + pu->szAvatarHash = remoteId.c_str(); + setString(pu->hContact, DBKEY_AVATAR_HASH, remoteId.c_str()); + SendQuery(new TD::downloadFile(pSmall->id_, 5, 0, 0, false)); + } + else delSetting(pu->hContact, DBKEY_AVATAR_HASH); + } + } + } + if (pUser->status_) { if (pUser->status_->get_id() == TD::userStatusOffline::ID) { auto *pOffline = (TD::userStatusOffline *)pUser->status_.get(); |