diff options
author | George Hazan <george.hazan@gmail.com> | 2023-06-03 18:31:18 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-06-03 18:31:18 +0300 |
commit | 6e83622d2af1cec3c759f4cff6efe4df2fe3328c (patch) | |
tree | 67a6224019f59e38d6496d32eefd72188bdbc61c /protocols/Telegram/src/server.cpp | |
parent | 6cade9acbd5067761f068ba819008eb3084239b4 (diff) |
Telegram: fix for a trick with temporary message id that led to duplicated messages
Diffstat (limited to 'protocols/Telegram/src/server.cpp')
-rw-r--r-- | protocols/Telegram/src/server.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 493b88bb7e..2bd4283763 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -181,7 +181,18 @@ void CTelegramProto::ProcessResponse(td::ClientManager::Response response) break;
case TD::updateMessageSendSucceeded::ID:
- ProcessMessage(((TD::updateMessageSendSucceeded *)response.object.get())->message_.get());
+ {
+ auto *pMessage = (TD::updateMessageSendSucceeded *)response.object.get();
+ ProcessMessage(pMessage->message_.get());
+
+ if (auto *pOwnMsg = m_arOwnMsg.find((TG_OWN_MESSAGE *)&pMessage->old_message_id_)) {
+ char szMsgId[100];
+ _i64toa(pMessage->message_->id_, szMsgId, 10);
+ ProtoBroadcastAck(pOwnMsg->hContact ? pOwnMsg->hContact : m_iSavedMessages, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, pOwnMsg->hAck, (LPARAM)szMsgId);
+
+ m_arOwnMsg.remove(pOwnMsg);
+ }
+ }
break;
case TD::updateNewChat::ID:
@@ -189,7 +200,11 @@ void CTelegramProto::ProcessResponse(td::ClientManager::Response response) break;
case TD::updateNewMessage::ID:
- ProcessMessage(((TD::updateNewMessage *)response.object.get())->message_.get());
+ {
+ auto *pMessage = ((TD::updateNewMessage *)response.object.get())->message_.get();
+ if (!m_arOwnMsg.find((TG_OWN_MESSAGE*)&pMessage->id_))
+ ProcessMessage(pMessage);
+ }
break;
case TD::updateOption::ID:
@@ -224,11 +239,8 @@ void CTelegramProto::OnSendMessage(td::ClientManager::Response &response, void * auto *pMessage = ((TD::message *)response.object.get());
auto *pUser = FindChat(pMessage->chat_id_);
- if (pUser) {
- char szMsgId[100];
- _i64toa(pMessage->id_, szMsgId, 10);
- ProtoBroadcastAck(pUser->hContact ? pUser->hContact : m_iSavedMessages, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, pUserInfo, (LPARAM)szMsgId);
- }
+ if (pUser)
+ m_arOwnMsg.insert(new TG_OWN_MESSAGE(pUser->hContact, pUserInfo, pMessage->id_));
}
int CTelegramProto::SendTextMessage(int64_t chatId, const char *pszMessage)
|