summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElzorFox <elzorfox@ya.ru>2024-10-22 10:30:37 +0500
committerElzorFox <elzorfox@ya.ru>2024-10-22 10:30:58 +0500
commit086a4572ba5c41ee8231d8c1a13288b42a4886c1 (patch)
tree213ed4136cf38c314d4009790e26924d5230e9a9
parent792207209ade53f715684de34f61029dd9752f06 (diff)
VKontakte: fix logic of marking message as remote read
-rw-r--r--protocols/VKontakte/src/misc.cpp23
-rw-r--r--protocols/VKontakte/src/vk_pollserver.cpp2
-rw-r--r--protocols/VKontakte/src/vk_proto.h2
3 files changed, 23 insertions, 4 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 13f1beba81..7ca85b9d3e 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -915,10 +915,29 @@ void CVkProto::MarkDialogAsRead(MCONTACT hContact)
}
}
-void CVkProto::MarkRemoteRead(MCONTACT hContact)
+void CVkProto::MarkRemoteRead(MCONTACT hContact, VKMessageID_t iMessageId)
{
- MEVENT hEvent = db_event_last(hContact);
+ MEVENT hEvent = 0;
+ if (iMessageId) {
+ char szMid[40];
+ _ltoa(iMessageId, szMid, 10);
+ hEvent = db_event_getById(m_szModuleName, szMid);
+ }
+ else
+ hEvent = db_event_last(hContact);
+
+ if (!hEvent)
+ return;
+
+ MEVENT hReadEvent = getDword(hContact, "RemoteRead");
+ if (hReadEvent) {
+ DB::EventInfo dbeiRead(hReadEvent);
+ VKMessageID_t iReadMessageId = strtol(strcat((char *)dbeiRead.szId, "_"), nullptr, 10);
+ if (iReadMessageId >= iMessageId)
+ return;
+ }
+
setDword(hContact, "LastMsgReadTime", time(0));
setDword(hContact, "RemoteRead", hEvent);
diff --git a/protocols/VKontakte/src/vk_pollserver.cpp b/protocols/VKontakte/src/vk_pollserver.cpp
index 52a8b92f06..d5916d8e47 100644
--- a/protocols/VKontakte/src/vk_pollserver.cpp
+++ b/protocols/VKontakte/src/vk_pollserver.cpp
@@ -104,7 +104,7 @@ void CVkProto::PollUpdates(const JSONNode &jnUpdates)
}
if (hContact != 0 && (iFlags & VKFLAG_MSGUNREAD) && !IsMessageExist(iMessageId, vkIN)) {
- MarkRemoteRead(hContact);
+ MarkRemoteRead(hContact, iMessageId);
if (m_vkOptions.bUserForceInvisibleOnActivity)
SetInvisible(hContact);
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index 1cdf42e861..368735e235 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -386,7 +386,7 @@ private:
void __cdecl ContactTypingThread(void *p);
int IsHystoryMessageExist(MCONTACT hContact);
void SetSrmmReadStatus(MCONTACT hContact);
- void MarkRemoteRead(MCONTACT hContact);
+ void MarkRemoteRead(MCONTACT hContact, VKMessageID_t iMessageId = 0);
void MarkDialogAsRead(MCONTACT hContact);
void CheckUpdate();
bool IsGroupUser(MCONTACT hContact);