summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-09-09 20:12:55 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-09-09 20:12:55 +0300
commit35e49b83894656aa8fd225c23fb794d15ed31506 (patch)
treeac99937c0d3f221f7e014b2b87db3954749e913a /protocols
parent26b746f2d8e99c18ccdfd3da1e318af8a890d2ef (diff)
fixes #4642 (Telegram: при приходе двух сообщений подряд, первое сразу помечается прочтённым)
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Telegram/src/server.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index 81ec9f3edd..119ffe2396 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -860,23 +860,21 @@ void CTelegramProto::ProcessMarkRead(TD::updateChatReadInbox *pObj)
if (pObj->last_read_inbox_message_id_)
pUser->bInited = true;
- MEVENT hLastRead = db_event_getById(m_szModuleName, msg2id(pObj->chat_id_, pObj->last_read_inbox_message_id_));
- if (hLastRead == 0) {
+ CMStringA szMaxId(msg2id(pObj->chat_id_, pObj->last_read_inbox_message_id_));
+ if (db_event_getById(m_szModuleName, szMaxId) == 0) {
debugLogA("unknown event, ignored");
return;
}
- bool bExit = false;
+ // make sure that all events with ids lower or equal than szMaxId are marked read
for (MEVENT hEvent = db_event_firstUnread(pUser->hContact); hEvent; hEvent = db_event_next(pUser->hContact, hEvent)) {
- if (bExit)
- break;
-
- bExit = (hEvent == hLastRead);
-
- DBEVENTINFO dbei = {};
- if (db_event_get(hEvent, &dbei))
+ DB::EventInfo dbei(hEvent, false);
+ if (!dbei || !dbei.szId)
continue;
+ if (dbei.szId > szMaxId)
+ break;
+
if (!dbei.markedRead())
db_event_markRead(pUser->hContact, hEvent, true);
}