diff options
author | George Hazan <george.hazan@gmail.com> | 2023-06-02 22:13:31 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-06-02 22:13:31 +0300 |
commit | fe8e65a6696f1a4623111125ad10019caf3141dd (patch) | |
tree | f6a642e331766f8debe327e174b2d7392e7627dc /protocols/Telegram/src/server.cpp | |
parent | c944dd795207f196ce64be39904506a58c9eac70 (diff) |
fixes #3392 ([Telegram] Add support for file transfers (images etc) both incoming and outgoing)
Diffstat (limited to 'protocols/Telegram/src/server.cpp')
-rw-r--r-- | protocols/Telegram/src/server.cpp | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 2b83443ec8..3b8ddda8ca 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -176,12 +176,20 @@ void CTelegramProto::ProcessResponse(td::ClientManager::Response response) ProcessFile((TD::updateFile *)response.object.get());
break;
+ case TD::updateMessageContent::ID:
+ ProcessMessageContent((TD::updateMessageContent *)response.object.get());
+ break;
+
+ case TD::updateMessageSendSucceeded::ID:
+ ProcessMessage(((TD::updateMessageSendSucceeded *)response.object.get())->message_.get());
+ break;
+
case TD::updateNewChat::ID:
ProcessChat((TD::updateNewChat *)response.object.get());
break;
case TD::updateNewMessage::ID:
- ProcessMessage((TD::updateNewMessage *)response.object.get());
+ ProcessMessage(((TD::updateNewMessage *)response.object.get())->message_.get());
break;
case TD::updateOption::ID:
@@ -588,16 +596,18 @@ void CTelegramProto::ProcessMarkRead(TD::updateChatReadInbox *pObj) }
}
-void CTelegramProto::ProcessMessage(TD::updateNewMessage *pObj)
+void CTelegramProto::ProcessMessage(const TD::message *pMessage)
{
- auto *pMessage = pObj->message_.get();
-
auto *pUser = FindChat(pMessage->chat_id_);
if (pUser == nullptr) {
debugLogA("message from unknown chat/user, ignored");
return;
}
+ if (pMessage->sending_state_)
+ if (pMessage->sending_state_->get_id() == TD::messageSendingStatePending::ID)
+ return;
+
CMStringA szText(GetMessageText(pUser, pMessage));
if (szText.IsEmpty()) {
debugLogA("this message was not processed, ignored");
@@ -629,6 +639,31 @@ void CTelegramProto::ProcessMessage(TD::updateNewMessage *pObj) ProtoChainRecvMsg((pUser->hContact) ? pUser->hContact : m_iSavedMessages, &pre);
}
+void CTelegramProto::ProcessMessageContent(TD::updateMessageContent *pObj)
+{
+ auto *pUser = FindChat(pObj->chat_id_);
+ if (pUser == nullptr) {
+ debugLogA("message from unknown chat/user, ignored");
+ return;
+ }
+
+ char szMsgId[100];
+ _i64toa(pObj->message_id_, szMsgId, 10);
+
+ MEVENT hDbEvent = db_event_getById(m_szModuleName, szMsgId);
+ if (hDbEvent == 0) {
+ debugLogA("Unknown message with id=%lld (chat id %lld, ignored", pObj->message_id_, pObj->chat_id_);
+ return;
+ }
+
+ /*
+ CMStringA szText(GetMessageText(pUser, pObj->new_content_.get()));
+ if (szText.IsEmpty()) {
+ debugLogA("this message was not processed, ignored");
+ return;
+ }*/
+}
+
void CTelegramProto::ProcessOption(TD::updateOption *pObj)
{
TD::int53 iValue = 0;
|