diff options
author | George Hazan <george.hazan@gmail.com> | 2023-12-12 19:53:18 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-12-12 19:53:18 +0300 |
commit | fb4c135b8674a43dd3e49c7bfc71b3d7b83f03ca (patch) | |
tree | 1e5fb4ed395136d08da7e3a44e02233fbdea823a /protocols/Telegram | |
parent | 73935f2710e73be9d992527cf323122728792d05 (diff) |
fixes #4043 (Telegram: problem with reply ids)
Diffstat (limited to 'protocols/Telegram')
-rw-r--r-- | protocols/Telegram/src/server.cpp | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 7965335227..51d427c531 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -754,12 +754,11 @@ void CTelegramProto::ProcessMessage(const TD::message *pMessage) if (pMessage->sending_state_->get_id() == TD::messageSendingStatePending::ID)
return;
- char szUserId[100], szReplyId[100];
+ char szUserId[100];
auto szMsgId(msg2id(pMessage));
- if (db_event_getById(m_szModuleName, szMsgId))
- return;
+ MEVENT hOldEvent = db_event_getById(m_szModuleName, szMsgId);
- CMStringA szText(GetMessageText(pUser, pMessage));
+ CMStringA szText(GetMessageText(pUser, pMessage)), szReplyId;
if (szText.IsEmpty()) {
debugLogA("this message was not processed, ignored");
return;
@@ -776,19 +775,37 @@ void CTelegramProto::ProcessMessage(const TD::message *pMessage) Contact::RemoveFromList(pUser->hContact);
}
- PROTORECVEVENT pre = {};
- pre.szMessage = szText.GetBuffer();
- pre.szMsgId = szMsgId;
- pre.timestamp = pMessage->date_;
- if (pMessage->is_outgoing_)
- pre.flags |= PREF_SENT;
- if (GetGcUserId(pUser, pMessage, szUserId))
- pre.szUserId = szUserId;
- if (pMessage->reply_to_message_id_) {
- _i64toa(pMessage->reply_to_message_id_, szReplyId, 10);
- pre.szReplyId = szReplyId;
+ if (hOldEvent) {
+ DB::EventInfo dbei(hOldEvent);
+ mir_free(dbei.pBlob);
+ dbei.cbBlob = szText.GetLength();
+ dbei.pBlob = (uint8_t *)szText.Detach();
+ dbei.timestamp = pMessage->date_;
+ if (pMessage->is_outgoing_)
+ dbei.flags |= DBEF_SENT;
+ if (GetGcUserId(pUser, pMessage, szUserId))
+ dbei.szUserId = szUserId;
+ if (pMessage->reply_to_message_id_) {
+ szReplyId = msg2id(pMessage->chat_id_, pMessage->reply_to_message_id_);
+ dbei.szReplyId = szReplyId;
+ }
+ db_event_edit(hOldEvent, &dbei, true);
+ }
+ else {
+ PROTORECVEVENT pre = {};
+ pre.szMessage = szText.GetBuffer();
+ pre.szMsgId = szMsgId;
+ pre.timestamp = pMessage->date_;
+ if (pMessage->is_outgoing_)
+ pre.flags |= PREF_SENT;
+ if (GetGcUserId(pUser, pMessage, szUserId))
+ pre.szUserId = szUserId;
+ if (pMessage->reply_to_message_id_) {
+ szReplyId = msg2id(pMessage->chat_id_, pMessage->reply_to_message_id_);
+ pre.szReplyId = szReplyId;
+ }
+ ProtoChainRecvMsg(GetRealContact(pUser), &pre);
}
- ProtoChainRecvMsg(GetRealContact(pUser), &pre);
}
void CTelegramProto::ProcessMessageContent(TD::updateMessageContent *pObj)
|