From 15bff8a1c1cdfad5c99d6cbb432e77062cd8162c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Tue, 15 Jul 2014 18:04:21 +0000 Subject: Facebook: Attempt to fix occasional sending/receiving duplicit messages git-svn-id: http://svn.miranda-ng.org/main/trunk@9815 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/FacebookRM/src/json.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'protocols/FacebookRM/src/json.cpp') diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index b12fe32378..2470738b21 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -281,16 +281,16 @@ bool ignore_duplicits(FacebookProto *proto, std::string mid, std::string text) { ScopedLock s(proto->facy.send_message_lock_); - std::map::iterator it = proto->facy.messages_ignore.find(mid); + std::map::iterator it = proto->facy.messages_ignore.find(mid); if (it != proto->facy.messages_ignore.end()) { proto->debugLogA("????? Ignoring duplicit/sent message\n%s", text.c_str()); - it->second = true; // mark to delete it at the end + it->second++; // increase counter (for deleting it later) return true; } // remember this id to ignore duplicits - proto->facy.messages_ignore.insert(std::make_pair(mid, true)); + proto->facy.messages_ignore.insert(std::make_pair(mid, 1)); return false; } @@ -373,11 +373,13 @@ void parseAttachments(FacebookProto *proto, std::string *message_text, JSONNODE int facebook_json_parser::parse_messages(void* data, std::vector< facebook_message* >* messages, std::map< std::string, facebook_notification* >* notifications, bool inboxOnly) { // remove old received messages from map - for (std::map::iterator it = proto->facy.messages_ignore.begin(); it != proto->facy.messages_ignore.end();) { - if (it->second) + for (std::map::iterator it = proto->facy.messages_ignore.begin(); it != proto->facy.messages_ignore.end();) { + if (it->second > FACEBOOK_IGNORE_COUNTER_LIMIT) { it = proto->facy.messages_ignore.erase(it); - else + } else { + it->second++; // increase counter on each request ++it; + } } std::string jsonData = static_cast< std::string* >(data)->substr(9); -- cgit v1.2.3