summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Telegram/src/proto.h1
-rw-r--r--protocols/Telegram/src/server.cpp23
2 files changed, 24 insertions, 0 deletions
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index 83909acf1f..d0cdd764c2 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -191,6 +191,7 @@ class CTelegramProto : public PROTO<CTelegramProto>
void ProcessChat(TD::updateNewChat *pObj);
void ProcessChatLastMessage(TD::updateChatLastMessage *pObj);
void ProcessChatPosition(TD::updateChatPosition *pObj);
+ void ProcessDeleteMessage(TD::updateDeleteMessages *pObj);
void ProcessFile(TD::updateFile *pObj);
void ProcessGroups(TD::updateChatFilters *pObj);
void ProcessMarkRead(TD::updateChatReadInbox *pObj);
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index d3a5afcacd..8611c6f625 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -150,6 +150,10 @@ void CTelegramProto::ProcessResponse(td::ClientManager::Response response)
ProcessMarkRead((TD::updateChatReadInbox *)response.object.get());
break;
+ case TD::updateDeleteMessages::ID:
+ ProcessDeleteMessage((TD::updateDeleteMessages*)response.object.get());
+ break;
+
case TD::updateFile::ID:
ProcessFile((TD::updateFile *)response.object.get());
break;
@@ -383,6 +387,25 @@ void CTelegramProto::ProcessChatPosition(TD::updateChatPosition *pObj)
}
}
+void CTelegramProto::ProcessDeleteMessage(TD::updateDeleteMessages *pObj)
+{
+ if (!pObj->is_permanent_)
+ return;
+
+ auto *pUser = FindChat(pObj->chat_id_);
+ if (pUser == nullptr || pUser->hContact == INVALID_CONTACT_ID) {
+ debugLogA("message from unknown chat, ignored");
+ return;
+ }
+
+ for (auto &it : pObj->message_ids_) {
+ char id[100];
+ _i64toa(it, id, 10);
+ if (MEVENT hEvent = db_event_getById(m_szModuleName, id))
+ db_event_delete(hEvent);
+ }
+}
+
void CTelegramProto::ProcessGroups(TD::updateChatFilters *pObj)
{
for (auto &grp : pObj->chat_filters_) {