From 81da71879b1b31adfc5577fb142811181ef3c95d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 28 Apr 2025 13:32:27 +0300 Subject: =?UTF-8?q?fixes=20#5003=20(Telegram:=20=D0=BF=D1=80=D0=BE=D0=B1?= =?UTF-8?q?=D0=BB=D0=B5=D0=BC=D1=8B=20=D1=81=20=D0=B8=D0=B7=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC=20=D0=BF=D0=BE=D0=B4=D0=BF?= =?UTF-8?q?=D0=B8=D1=81=D0=B8=20=D0=BA=20=D1=84=D0=B0=D0=B9=D0=BB=D1=83)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Telegram/src/server.cpp | 12 ++++++------ protocols/Telegram/src/utils.cpp | 16 +++++++++++----- 2 files changed, 17 insertions(+), 11 deletions(-) (limited to 'protocols/Telegram/src') diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 0c144c1e6f..b6b987454b 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -962,12 +962,6 @@ void CTelegramProto::ProcessMessage(const TD::message *pMessage) auto szMsgId(msg2id(pMessage)); MEVENT hOldEvent = db_event_getById(m_szModuleName, szMsgId); - CMStringA szText(GetMessageText(pUser, pMessage)), szReplyId; - if (szText.IsEmpty()) { - debugLogA("this message was not processed, ignored"); - return; - } - // make a temporary contact if needed if (pUser->hContact == INVALID_CONTACT_ID) { if (pUser->isGroupChat) { @@ -979,6 +973,12 @@ void CTelegramProto::ProcessMessage(const TD::message *pMessage) Contact::RemoveFromList(pUser->hContact); } + CMStringA szText(GetMessageText(pUser, pMessage)), szReplyId; + if (szText.IsEmpty()) { + debugLogA("this message was not processed, ignored"); + return; + } + MCONTACT hContact = GetRealContact(pUser, pMessage->message_thread_id_); if (m_bResidentChannels && pUser->isChannel && pUser->m_si) { diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index 13983cb2b2..6a2c043fb6 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -152,7 +152,11 @@ CMStringA msg2id(TD::int53 chatId, TD::int53 msgId) CMStringA msg2id(const TD::message *pMsg) { - return CMStringA(FORMAT, "%lld_%lld", pMsg->chat_id_, pMsg->id_); + auto iChatId = pMsg->chat_id_; + if (!iChatId && pMsg->sender_id_->get_id() == TD::messageSenderChat::ID) + iChatId = ((TD::messageSenderChat *)pMsg->sender_id_.get())->chat_id_; + + return CMStringA(FORMAT, "%lld_%lld", iChatId, pMsg->id_); } TD::int53 dbei2id(const DBEVENTINFO &dbei) @@ -520,14 +524,15 @@ bool CTelegramProto::GetMessageFile(const EmbeddedFile &F, TG_FILE_REQUEST::Type char szReplyId[100]; DB::EventInfo dbei(db_event_getById(m_szModuleName, F.pszId)); - dbei.flags = DBEF_TEMPORARY; - dbei.iTimestamp = F.pMsg->date_; + dbei.bTemporary = true; dbei.szId = F.pszId; dbei.szUserId = F.pszUser; + if (F.pMsg->date_) + dbei.iTimestamp = F.pMsg->date_; if (F.pMsg->is_outgoing_) - dbei.flags |= DBEF_SENT | DBEF_READ; + dbei.bSent = dbei.bRead = true; if (!F.pUser->bInited || F.bRead) - dbei.flags |= DBEF_READ; + dbei.bRead = true; if (auto iReplyId = getReplyId(F.pMsg->reply_to_.get())) { _i64toa(iReplyId, szReplyId, 10); dbei.szReplyId = szReplyId; @@ -536,6 +541,7 @@ bool CTelegramProto::GetMessageFile(const EmbeddedFile &F, TG_FILE_REQUEST::Type if (dbei) { if (!Ignore_IsIgnored(pRequest->m_hContact, IGNOREEVENT_FILE)) { DB::FILE_BLOB blob(dbei); + blob.setDescr(Utf2T(pszCaption)); OnReceiveOfflineFile(dbei, blob); blob.write(dbei); db_event_edit(dbei.getEvent(), &dbei, true); -- cgit v1.2.3