summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElzorFox <elzorfox@ya.ru>2018-10-06 17:10:29 +0500
committerElzorFox <elzorfox@ya.ru>2018-10-06 17:11:12 +0500
commit148440271b10b2e690175b399a21b5c59af3481c (patch)
treee9a25b08ae2578e3d4fd538f2ec96c3c1e4d3e85
parentb1820641624e8882ded14306fba687f5e5cd75cd (diff)
VKontakte:
support deleted messages version bump
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk_pollserver.cpp45
2 files changed, 46 insertions, 1 deletions
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index 15891a286b..f9ea7ee788 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 3
+#define __BUILD_NUM 4
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_pollserver.cpp b/protocols/VKontakte/src/vk_pollserver.cpp
index 1f95f2954a..5fa6554b0f 100644
--- a/protocols/VKontakte/src/vk_pollserver.cpp
+++ b/protocols/VKontakte/src/vk_pollserver.cpp
@@ -79,6 +79,8 @@ void CVkProto::PollUpdates(const JSONNode &jnUpdates)
CMStringA mids;
int msgid, uid, flags, platform;
MCONTACT hContact;
+ UINT datetime = 0;
+ CMStringW wszMsg;
for (auto &it : jnUpdates) {
const JSONNode &jnChild = it.as_array();
@@ -91,6 +93,12 @@ void CVkProto::PollUpdates(const JSONNode &jnUpdates)
uid = jnChild[3].as_int();
hContact = FindUser(uid);
+ if (hContact != 0 && (flags & VKFLAG_MSGDELETED)) {
+ if (!mids.IsEmpty())
+ mids.AppendChar(',');
+ mids.AppendFormat("%d", msgid);
+ }
+
if (hContact != 0 && (flags & VKFLAG_MSGUNREAD) && !IsMessageExist(msgid, vkIN)) {
setDword(hContact, "LastMsgReadTime", time(0));
if (ServiceExists(MS_MESSAGESTATE_UPDATE)) {
@@ -106,6 +114,43 @@ void CVkProto::PollUpdates(const JSONNode &jnUpdates)
}
break;
+ case VKPOLL_MSG_ADDFLAGS:
+ if (jnChild.size() < 4)
+ break;
+ msgid = jnChild[1].as_int();
+ flags = jnChild[2].as_int();
+ uid = jnChild[3].as_int();
+ hContact = FindUser(uid);
+
+ if (hContact != 0 && (flags & VKFLAG_MSGDELETED) && IsMessageExist(msgid, vkALL) && GetMessageFromDb(msgid, datetime, wszMsg)) {
+ wchar_t ttime[64];
+ time_t delete_time = time(0);
+ _locale_t locale = _create_locale(LC_ALL, "");
+ _wcsftime_l(ttime, _countof(ttime), TranslateT("%x at %X"), localtime(&delete_time), locale);
+ _free_locale(locale);
+
+ wszMsg = SetBBCString(
+ CMStringW(FORMAT, TranslateT("This message has been deleted by sender in %s:\n"), ttime),
+ m_vkOptions.BBCForAttachments(), vkbbcB) +
+ wszMsg;
+
+ PROTORECVEVENT recv = {};
+ if (uid == m_myUserId)
+ recv.flags |= PREF_SENT;
+ else if (m_vkOptions.bUserForceInvisibleOnActivity && time(0) - datetime < 60 * m_vkOptions.iInvisibleInterval)
+ SetInvisible(hContact);
+
+ char szMid[40];
+ _itoa(msgid, szMid, 10);
+
+ T2Utf pszMsg(wszMsg);
+ recv.timestamp = datetime;
+ recv.szMessage = pszMsg;
+ recv.szMsgId = szMid;
+ ProtoChainRecvMsg(hContact, &recv);
+ }
+ break;
+
case VKPOLL_MSG_EDITED:
msgid = jnChild[1].as_int();
if (!mids.IsEmpty())