From 51cb1a0a2101fc6d7b8376f5d07adbede24f56a9 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 26 Jan 2017 17:37:16 +0300 Subject: fix of marking unread events as read --- protocols/Discord/src/server.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'protocols/Discord/src/server.cpp') diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp index a818622d67..b87bc4eaf8 100644 --- a/protocols/Discord/src/server.cpp +++ b/protocols/Discord/src/server.cpp @@ -60,7 +60,7 @@ void CDiscordProto::OnReceiveHistory(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest DBEVENTINFO dbei = {}; dbei.szModule = m_szModuleName; - dbei.flags = DBEF_READ | DBEF_UTF; + dbei.flags = DBEF_UTF; dbei.eventType = EVENTTYPE_MESSAGE; SnowFlake lastId = getId(pUser->hContact, DB_KEY_LASTMSGID); // as stored in a database @@ -76,6 +76,10 @@ void CDiscordProto::OnReceiveHistory(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest dbei.flags &= ~DBEF_SENT; SnowFlake msgid = _wtoi64(p["id"].as_mstring()); + if (msgid <= pUser->lastReadId) + dbei.flags |= DBEF_READ; + else + dbei.flags &= ~DBEF_READ; CMStringA szBody(ptrA(mir_utf8encodeW(p["content"].as_mstring()))); szBody.AppendFormat("%c%lld", 0, msgid); -- cgit v1.2.3