diff options
author | George Hazan <george.hazan@gmail.com> | 2023-07-26 17:02:53 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-07-26 17:02:53 +0300 |
commit | e0bf792776131deef8f2634fb3eeb8bd8239c059 (patch) | |
tree | a004484e81d10505af43d1efa66726d4a9bb6d39 /protocols/Telegram/src/proto.cpp | |
parent | 6f0837663b1aac2ede278e7dd8fb416290f82dad (diff) |
.
Diffstat (limited to 'protocols/Telegram/src/proto.cpp')
-rw-r--r-- | protocols/Telegram/src/proto.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp index 731d7babf1..849c0469f8 100644 --- a/protocols/Telegram/src/proto.cpp +++ b/protocols/Telegram/src/proto.cpp @@ -415,11 +415,36 @@ HANDLE CTelegramProto::SendFile(MCONTACT hContact, const wchar_t *szDescription, return pTransfer; } -void CTelegramProto::OnSendFile(td::ClientManager::Response &, void *pUserInfo) +void CTelegramProto::OnSendFile(td::ClientManager::Response &response, void *pUserInfo) { auto *ft = (TG_FILE_REQUEST *)pUserInfo; + + if (response.object->get_id() == TD::message::ID) { + auto *pMsg = (TD::message *)response.object.get(); + ft->m_uniqueId.Format("%lld", pMsg->id_); + + if (auto *pUser = FindChat(pMsg->chat_id_)) { + char szUserId[100]; + if (this->GetGcUserId(pUser, pMsg, szUserId)) + ft->m_szUserId = szUserId; + + auto *pOwnMsg = new TG_OWN_MESSAGE(pUser->hContact, 0, pMsg->id_); + const TD::MessageContent *pBody = pMsg->content_.get(); + switch (pBody->get_id()) { + case TD::messagePhoto::ID: + pOwnMsg->tmpFileId = ((TD::messagePhoto*)pBody)->photo_->sizes_[0]->photo_->id_; + break; + + case TD::messageDocument::ID: + pOwnMsg->tmpFileId = ((TD::messageDocument *)pBody)->document_->document_->id_; + break; + } + m_arOwnMsg.insert(pOwnMsg); + } + } + ProtoBroadcastAck(ft->m_hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft); - delete ft; + delete ft; } ///////////////////////////////////////////////////////////////////////////////////////// |