summaryrefslogtreecommitdiff
path: root/protocols/Telegram
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-01-27 20:23:20 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-01-27 20:23:20 +0300
commitd18fdf58c517c957809e9ec0b8044a05984de7c6 (patch)
tree795967aee27142f012f47e739b1bbb31c53b7450 /protocols/Telegram
parentabc610a264a0a9c03effe579283c7d4c4fdf08b5 (diff)
fixes #4140 (NewStory: удаление отдельных сообщений)
Diffstat (limited to 'protocols/Telegram')
-rw-r--r--protocols/Telegram/src/proto.cpp26
-rw-r--r--protocols/Telegram/src/proto.h3
-rw-r--r--protocols/Telegram/src/server.cpp4
3 files changed, 18 insertions, 15 deletions
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp
index 3b79b01e66..f1315dc56d 100644
--- a/protocols/Telegram/src/proto.cpp
+++ b/protocols/Telegram/src/proto.cpp
@@ -214,9 +214,9 @@ void CTelegramProto::OnErase()
DeleteDirectoryTreeW(GetProtoFolder(), false);
}
-void CTelegramProto::OnEventDeleted(MCONTACT hContact, MEVENT hDbEvent)
+void CTelegramProto::OnEventDeleted(MCONTACT hContact, MEVENT hDbEvent, int flags)
{
- if (!hContact)
+ if (!hContact || !(flags & CDF_FROM_SERVER))
return;
auto *pUser = FindUser(GetId(hContact));
@@ -224,19 +224,21 @@ void CTelegramProto::OnEventDeleted(MCONTACT hContact, MEVENT hDbEvent)
return;
DB::EventInfo dbei(hDbEvent, false);
- if (dbei.szId) {
- mir_cslock lck(m_csDeleteMsg);
- if (m_deleteChatId) {
- if (m_deleteChatId != pUser->chatId)
- SendDeleteMsg();
+ if (!dbei.szId)
+ return;
- m_impl.m_deleteMsg.Stop();
- }
+ mir_cslock lck(m_csDeleteMsg);
+ if (m_deleteChatId) {
+ if (m_deleteChatId != pUser->chatId)
+ SendDeleteMsg();
- m_deleteChatId = pUser->chatId;
- m_deleteIds.push_back(dbei2id(dbei));
- m_impl.m_deleteMsg.Start(500);
+ m_impl.m_deleteMsg.Stop();
}
+
+ m_bDeleteForAll = (flags & CDF_FOR_EVERYONE) != 0;
+ m_deleteChatId = pUser->chatId;
+ m_deleteIds.push_back(dbei2id(dbei));
+ m_impl.m_deleteMsg.Start(500);
}
void CTelegramProto::OnEventEdited(MCONTACT hContact, MEVENT, const DBEVENTINFO &dbei)
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index 800a718740..830b937e05 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -198,6 +198,7 @@ class CTelegramProto : public PROTO<CTelegramProto>
TD::array<TD::int53> m_markIds;
mir_cs m_csDeleteMsg;
+ bool m_bDeleteForAll;
TD::int53 m_deleteChatId = 0;
TD::array<TD::int53> m_deleteIds;
@@ -370,7 +371,7 @@ public:
bool OnContactDeleted(MCONTACT hContact, uint32_t flags) override;
MWindow OnCreateAccMgrUI(MWindow hwndParent) override;
void OnErase() override;
- void OnEventDeleted(MCONTACT, MEVENT) override;
+ void OnEventDeleted(MCONTACT, MEVENT, int) override;
void OnEventEdited(MCONTACT, MEVENT, const DBEVENTINFO &dbei) override;
void OnMarkRead(MCONTACT, MEVENT) override;
void OnModulesLoaded() override;
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index 78f4f43134..2082a73e13 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -152,7 +152,7 @@ void CTelegramProto::SendDeleteMsg()
m_impl.m_deleteMsg.Stop();
mir_cslock lck(m_csDeleteMsg);
- SendQuery(new TD::deleteMessages(m_deleteChatId, std::move(m_deleteIds), true));
+ SendQuery(new TD::deleteMessages(m_deleteChatId, std::move(m_deleteIds), m_bDeleteForAll));
m_deleteChatId = 0;
}
@@ -694,7 +694,7 @@ void CTelegramProto::ProcessDeleteMessage(TD::updateDeleteMessages *pObj)
for (auto &it : pObj->message_ids_)
if (MEVENT hEvent = db_event_getById(m_szModuleName, msg2id(pObj->chat_id_, it)))
- db_event_delete(hEvent, true);
+ db_event_delete(hEvent, CDF_FROM_SERVER);
}
void CTelegramProto::ProcessGroups(TD::updateChatFolders *pObj)