From dafbc9f884d3c696ecaadb9e32b90e831b04427a Mon Sep 17 00:00:00 2001 From: ElzorFox Date: Sat, 22 Sep 2018 15:04:18 +0500 Subject: VKontakte: more correct protection from duplicate messages --- protocols/VKontakte/src/misc.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'protocols/VKontakte/src/misc.cpp') 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 ×tamp, CMStringW &msg) +{ + char szMid[40]; + _itoa(iMsgId, szMid, 10); + return GetMessageFromDb(szMid, timestamp, msg); +} + MEVENT CVkProto::GetMessageFromDb(const char *messageId, UINT ×tamp, 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)); +} -- cgit v1.2.3