diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2015-09-05 11:13:06 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2015-09-05 11:13:06 +0000 |
commit | faae47984c5b3d91a771a4c7b10ffe2baf4ad8a9 (patch) | |
tree | fa2f6da871c3e850291761b2d902c1b0d314d5cf /protocols | |
parent | f076011ddab109f2a046410ffab8255c71ad7390 (diff) |
VKontakte: MessageState api for history import
git-svn-id: http://svn.miranda-ng.org/main/trunk@15254 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/VKontakte/src/vk_history.cpp | 9 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_pollserver.cpp | 3 |
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);
}
|