summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/Telegram/src/server.cpp12
-rw-r--r--protocols/Telegram/src/utils.cpp16
2 files changed, 17 insertions, 11 deletions
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);