summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/json.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-07-15 18:04:21 +0000
committerRobert Pösel <robyer@seznam.cz>2014-07-15 18:04:21 +0000
commit15bff8a1c1cdfad5c99d6cbb432e77062cd8162c (patch)
tree35d4d3f1a113a9bd0b0140ec75d0a5bb5cd67479 /protocols/FacebookRM/src/json.cpp
parentf7ce999c47164638788ba359ad96d99206aee44d (diff)
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
Diffstat (limited to 'protocols/FacebookRM/src/json.cpp')
-rw-r--r--protocols/FacebookRM/src/json.cpp14
1 files changed, 8 insertions, 6 deletions
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<std::string, bool>::iterator it = proto->facy.messages_ignore.find(mid);
+ std::map<std::string, int>::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<std::string, bool>::iterator it = proto->facy.messages_ignore.begin(); it != proto->facy.messages_ignore.end();) {
- if (it->second)
+ for (std::map<std::string, int>::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);