summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/VKontakte/src/vk_history.cpp9
-rw-r--r--protocols/VKontakte/src/vk_pollserver.cpp3
2 files changed, 10 insertions, 2 deletions
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp
index c7142ef726..b0fd49772b 100644
--- a/protocols/VKontakte/src/vk_history.cpp
+++ b/protocols/VKontakte/src/vk_history.cpp
@@ -183,6 +183,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
const JSONNode &jnFUsers = jnResponse["fwd_users"];
int iLastMsgId = getDword(param->hContact, "lastmsgid", -1);
+ time_t tLastReadMessageTime = 0;
int count = 0;
for (auto it = jnMsgs.rbegin(); it != jnMsgs.rend(); ++it) {
@@ -231,10 +232,18 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
recv.cbCustomDataSize = (int)mir_strlen(szMid);
ProtoChainRecvMsg(hContact, &recv);
+ if (isRead && isOut && datetime > tLastReadMessageTime)
+ tLastReadMessageTime = datetime;
+
count++;
}
setDword(param->hContact, "lastmsgid", iLastMsgId);
+ if (ServiceExists(MS_MESSAGESTATE_UPDATE)) {
+ MessageReadData data(tLastReadMessageTime, MRD_TYPE_MESSAGETIME);
+ CallService(MS_MESSAGESTATE_UPDATE, param->hContact, (LPARAM)&data);
+ }
+
int once = jnResponse["once"].as_int();
int iRCount = jnResponse["rcount"].as_int();
if (count == iRCount && once == 0)
diff --git a/protocols/VKontakte/src/vk_pollserver.cpp b/protocols/VKontakte/src/vk_pollserver.cpp
index f835fbc510..e10d36c296 100644
--- a/protocols/VKontakte/src/vk_pollserver.cpp
+++ b/protocols/VKontakte/src/vk_pollserver.cpp
@@ -87,8 +87,7 @@ void CVkProto::PollUpdates(const JSONNode &jnUpdates)
if (hContact != NULL && (flags & VKFLAG_MSGUNREAD) && !CheckMid(m_incIds, msgid)) {
setDword(hContact, "LastMsgReadTime", time(NULL));
- if (ServiceExists(MS_MESSAGESTATE_UPDATE))
- {
+ if (ServiceExists(MS_MESSAGESTATE_UPDATE)) {
MessageReadData data(time(NULL), MRD_TYPE_READTIME);
CallService(MS_MESSAGESTATE_UPDATE, hContact, (LPARAM)&data);
}