From 86c868a76a5ba3d638b3b7302cd5401df06591d8 Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Wed, 9 Sep 2015 17:54:07 +0000 Subject: VKontakte: fix for MessageState git-svn-id: http://svn.miranda-ng.org/main/trunk@15315 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/vk_messages.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'protocols/VKontakte') diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index 3e26356f61..ad75928ae9 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -332,17 +332,35 @@ void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) if (jnDlg == NULL) break; + int uid = 0; + MCONTACT hContact(NULL); + int chatid = jnDlg["chat_id"].as_int(); - if (chatid != 0) { + + if (!chatid) { + uid = jnDlg["user_id"].as_int(); + hContact = FindUser(uid, true); + + if (ServiceExists(MS_MESSAGESTATE_UPDATE)) { + time_t tLastReadMessageTime = jnDlg["date"].as_int(); + bool isOut = jnDlg["out"].as_bool(); + bool isRead = jnDlg["read_state"].as_bool(); + + if (isRead && isOut) { + MessageReadData data(tLastReadMessageTime, MRD_TYPE_MESSAGETIME); + CallService(MS_MESSAGESTATE_UPDATE, hContact, (LPARAM)&data); + } + } + } + + if (chatid) { debugLogA("CVkProto::OnReceiveDlgs chatid = %d", chatid); if (m_chats.find((CVkChatInfo*)&chatid) == NULL) AppendChat(chatid, jnDlg); } else if (m_iSyncHistoryMetod) { int mid = jnDlg["id"].as_int(); - int uid = jnDlg["user_id"].as_int(); - MCONTACT hContact = FindUser(uid, true); - + if (getDword(hContact, "lastmsgid", -1) == -1 && numUnread) GetServerHistory(hContact, 0, numUnread, 0, 0, true); else @@ -352,8 +370,6 @@ void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) MarkMessagesRead(hContact); } else if (numUnread) { - int uid = jnDlg["user_id"].as_int(); - MCONTACT hContact = FindUser(uid, true); GetServerHistory(hContact, 0, numUnread, 0, 0, true); if (m_iMarkMessageReadOn == markOnReceive) -- cgit v1.2.3