From 39fb3e8fa1f2603bdca1cf005d382c18b0f3f993 Mon Sep 17 00:00:00 2001 From: ElzorFox Date: Wed, 3 Oct 2018 17:31:42 +0500 Subject: VKontakte: history synchronization without deleting messages version bump --- protocols/VKontakte/src/version.h | 2 +- protocols/VKontakte/src/vk_history.cpp | 32 +++++++++++++++++++------------- protocols/VKontakte/src/vk_messages.cpp | 1 + 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index 2f84f0faaa..15891a286b 100644 --- a/protocols/VKontakte/src/version.h +++ b/protocols/VKontakte/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 1 #define __RELEASE_NUM 6 -#define __BUILD_NUM 2 +#define __BUILD_NUM 3 #include diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index dab77003d9..e6271b6835 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -104,21 +104,23 @@ void CVkProto::GetServerHistoryLastNDay(MCONTACT hContact, int NDay) time_t tTime = time(0) - 60 * 60 * 24 * NDay; - MEVENT hDBEvent = db_event_first(hContact); - while (hDBEvent) { - MEVENT hDBEventNext = db_event_next(hContact, hDBEvent); - DBEVENTINFO dbei = {}; - db_event_get(hDBEvent, &dbei); - if (dbei.timestamp > tTime && dbei.eventType != VK_USER_DEACTIVATE_ACTION) - db_event_delete(hContact, hDBEvent); - hDBEvent = hDBEventNext; - } + if (NDay > 3) { + MEVENT hDBEvent = db_event_first(hContact); + while (hDBEvent) { + MEVENT hDBEventNext = db_event_next(hContact, hDBEvent); + DBEVENTINFO dbei = {}; + db_event_get(hDBEvent, &dbei); + if (dbei.timestamp > tTime && dbei.eventType != VK_USER_DEACTIVATE_ACTION) + db_event_delete(hContact, hDBEvent); + hDBEvent = hDBEventNext; + } - { - mir_cslock lck(m_csLoadHistoryTask); - m_iLoadHistoryTask++; - if (NDay > 3) + { + mir_cslock lck(m_csLoadHistoryTask); + m_iLoadHistoryTask++; m_bNotifyForEndLoadingHistory = true; + } + } setDword(hContact, "oldlastmsgid", getDword(hContact, "lastmsgid", -1)); @@ -295,6 +297,10 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque recv.szMsgId = szMid; ProtoChainRecvMsg(hContact, &recv); + MEVENT hDbEvent = db_event_getById(m_szModuleName, strcat(szMid, "_")); + if (hDbEvent) + db_event_delete(hContact, hDbEvent); + if (isRead && isOut && datetime > tLastReadMessageTime) tLastReadMessageTime = datetime; diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index fd91d769f0..60c6bf5207 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -343,6 +343,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe T2Utf pszAttach(wszAttachmentDescr); recv.timestamp = time(0); // only local time recv.szMessage = pszAttach; + recv.szMsgId = strcat(szMid, "_"); ProtoChainRecvMsg(hContact, &recv); } } -- cgit v1.2.3