From 285bec1935c0776b761374d8e545a6a5af7f96c9 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 7 Jun 2023 19:02:15 +0300 Subject: =?UTF-8?q?fixes=20#3544=20(Telegram:=20=D0=BD=D0=B5=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82=20=D0=B7=D0=B0=D0=B3?= =?UTF-8?q?=D1=80=D1=83=D0=B7=D0=BA=D0=B0=20=D0=B8=D1=81=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=B4=D0=BB=D1=8F=20Saved=20messages)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Telegram/src/proto.h | 2 ++ protocols/Telegram/src/server.cpp | 6 ++++-- protocols/Telegram/src/utils.cpp | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'protocols/Telegram/src') diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index 0e87fec62c..3142f65826 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -294,6 +294,8 @@ class CTelegramProto : public PROTO int64_t GetId(MCONTACT); void SetId(MCONTACT, int64_t id); + MCONTACT GetRealContact(const TG_USER *pUser); + // Menus HGENMENU hmiForward; diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 90fa86a76b..c8eba7f5ae 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -317,6 +317,8 @@ void CTelegramProto::OnGetHistory(td::ClientManager::Response &response, void *p continue; CMStringA szBody = GetMessageText(pUser, pMsg); + if (szBody.IsEmpty()) + continue; DBEVENTINFO dbei = {}; dbei.eventType = EVENTTYPE_MESSAGE; @@ -330,7 +332,7 @@ void CTelegramProto::OnGetHistory(td::ClientManager::Response &response, void *p dbei.flags |= DBEF_SENT; if (this->GetGcUserId(pUser, pMsg, szUserId)) dbei.szUserId = szUserId; - db_event_add(pUser->hContact, &dbei); + db_event_add(GetRealContact(pUser), &dbei); } if (lastMsgId != INT64_MAX) @@ -650,7 +652,7 @@ void CTelegramProto::ProcessMessage(const TD::message *pMessage) pre.flags |= PREF_SENT; if (GetGcUserId(pUser, pMessage, szUserId)) pre.szUserId = szUserId; - ProtoChainRecvMsg((pUser->hContact) ? pUser->hContact : m_iSavedMessages, &pre); + ProtoChainRecvMsg(GetRealContact(pUser), &pre); } void CTelegramProto::ProcessMessageContent(TD::updateMessageContent *pObj) diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index 6ed1bff00d..eab4d893f6 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -55,6 +55,11 @@ CMStringW TG_USER::getDisplayName() const return wszNick; } +MCONTACT CTelegramProto::GetRealContact(const TG_USER *pUser) +{ + return (pUser->hContact != 0) ? pUser->hContact : m_iSavedMessages; +} + TG_USER* CTelegramProto::GetSender(const TD::MessageSender *pSender) { switch (pSender->get_id()) { -- cgit v1.2.3