summaryrefslogtreecommitdiff
path: root/protocols/Telegram/src/proto.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-07-26 17:02:53 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-07-26 17:02:53 +0300
commite0bf792776131deef8f2634fb3eeb8bd8239c059 (patch)
treea004484e81d10505af43d1efa66726d4a9bb6d39 /protocols/Telegram/src/proto.cpp
parent6f0837663b1aac2ede278e7dd8fb416290f82dad (diff)
.
Diffstat (limited to 'protocols/Telegram/src/proto.cpp')
-rw-r--r--protocols/Telegram/src/proto.cpp29
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;
}
/////////////////////////////////////////////////////////////////////////////////////////