summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/misc.cpp
diff options
context:
space:
mode:
authorElzorFox <elzorfox@ya.ru>2018-09-22 15:04:18 +0500
committerElzorFox <elzorfox@ya.ru>2018-09-22 15:04:18 +0500
commitdafbc9f884d3c696ecaadb9e32b90e831b04427a (patch)
tree88aef6eca36b44558bcc5031d14694fdb5ccce0a /protocols/VKontakte/src/misc.cpp
parentdfc40eb5c9d357c7cd5e8cb0e9e6f2173b4935ef (diff)
VKontakte: more correct protection from duplicate messages
Diffstat (limited to 'protocols/VKontakte/src/misc.cpp')
-rw-r--r--protocols/VKontakte/src/misc.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 847250b6ef..d4af4c1a8c 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -1539,6 +1539,14 @@ void CVkProto::AddVkDeactivateEvent(MCONTACT hContact, CMStringW& wszType)
db_event_add(hContact, &dbei);
}
+
+MEVENT CVkProto::GetMessageFromDb(UINT iMsgId, UINT &timestamp, CMStringW &msg)
+{
+ char szMid[40];
+ _itoa(iMsgId, szMid, 10);
+ return GetMessageFromDb(szMid, timestamp, msg);
+}
+
MEVENT CVkProto::GetMessageFromDb(const char *messageId, UINT &timestamp, CMStringW &msg)
{
if (messageId == nullptr)
@@ -1566,10 +1574,22 @@ int CVkProto::DeleteContact(MCONTACT hContact)
return db_delete_contact(hContact);
}
-bool CVkProto::IsMessageExist(UINT MsgId)
+bool CVkProto::IsMessageExist(UINT iMsgId, VKMesType vkType)
{
char szMid[40];
- _itoa(MsgId, szMid, 10);
+ _itoa(iMsgId, szMid, 10);
+
+ MEVENT hDbEvent = db_event_getById(m_szModuleName, szMid);
- return (db_event_getById(m_szModuleName, szMid) != 0);
-} \ No newline at end of file
+ if (!hDbEvent)
+ return false;
+
+ if (vkType == vkALL)
+ return true;
+
+ DBEVENTINFO dbei = {};
+ if(db_event_get(hDbEvent, &dbei))
+ return false;
+
+ return ((vkType == vkOUT) == (bool)(dbei.flags & DBEF_SENT));
+}