From d18fdf58c517c957809e9ec0b8044a05984de7c6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 27 Jan 2024 20:23:20 +0300 Subject: =?UTF-8?q?fixes=20#4140=20(NewStory:=20=D1=83=D0=B4=D0=B0=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=82=D0=B4=D0=B5=D0=BB=D1=8C?= =?UTF-8?q?=D0=BD=D1=8B=D1=85=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Telegram/src/proto.cpp | 26 ++++++++++++++------------ protocols/Telegram/src/proto.h | 3 ++- protocols/Telegram/src/server.cpp | 4 ++-- 3 files changed, 18 insertions(+), 15 deletions(-) (limited to 'protocols/Telegram') 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 TD::array m_markIds; mir_cs m_csDeleteMsg; + bool m_bDeleteForAll; TD::int53 m_deleteChatId = 0; TD::array 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) -- cgit v1.2.3