From faae47984c5b3d91a771a4c7b10ffe2baf4ad8a9 Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Sat, 5 Sep 2015 11:13:06 +0000 Subject: VKontakte: MessageState api for history import git-svn-id: http://svn.miranda-ng.org/main/trunk@15254 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/vk_history.cpp | 9 +++++++++ protocols/VKontakte/src/vk_pollserver.cpp | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'protocols') 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); } -- cgit v1.2.3