summaryrefslogtreecommitdiff
path: root/protocols/Telegram/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Telegram/src')
-rw-r--r--protocols/Telegram/src/proto.h2
-rw-r--r--protocols/Telegram/src/server.cpp10
2 files changed, 8 insertions, 4 deletions
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index f00e59353f..64a4fab6ad 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -99,7 +99,7 @@ struct TG_USER : public MZeroedObject
delete pReactions;
}
- int64_t id, chatId = -1, forumId = -1;
+ int64_t id, chatId = -1, forumId = -1, lastReadId;
MCONTACT hContact;
int folderId = -1, nTopics;
bool isGroupChat, isChannel, isBot, isForum, bLoadMembers, bStartChat, bInited, bDelOwn = true, bDelAll = true;
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index 714347b229..9ecd5ff29a 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -922,8 +922,10 @@ void CTelegramProto::ProcessMarkRead(TD::updateChatReadInbox *pObj)
return;
}
- if (pObj->last_read_inbox_message_id_)
+ if (pObj->last_read_inbox_message_id_) {
pUser->bInited = true;
+ pUser->lastReadId = pObj->last_read_inbox_message_id_;
+ }
CMStringA szMaxId(msg2id(pObj->chat_id_, pObj->last_read_inbox_message_id_));
if (db_event_getById(m_szModuleName, szMaxId) == 0) {
@@ -992,9 +994,11 @@ void CTelegramProto::ProcessMessage(const TD::message *pMessage)
dbei.cbBlob = szText.GetLength();
dbei.iTimestamp = pMessage->date_;
if (pMessage->is_outgoing_)
- dbei.flags |= DBEF_SENT | DBEF_READ;
+ dbei.bSent = dbei.bRead = true;
+ else if (pMessage->id_ <= pUser->lastReadId)
+ dbei.bRead = true;
if (!pUser->bInited)
- dbei.flags |= DBEF_READ;
+ dbei.bRead = true;
if (GetGcUserId(pUser, pMessage, szUserId))
dbei.szUserId = szUserId;
if (auto iReplyId = getReplyId(pMessage->reply_to_.get())) {