diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-03-15 11:12:14 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-03-15 11:12:14 +0000 |
commit | 2f23f177d8ffcb7e65c52fc7c28b9cb269be8abb (patch) | |
tree | b50a4def109591c388992404d97bde714aaab233 /protocols/FacebookRM | |
parent | a7161575512b0b043c025fd2efbbc612d309c56d (diff) |
Facebook: fix showing duplicates of sent messages (at the cost of slowing down whole processing and sending only one message at a time :()
git-svn-id: http://svn.miranda-ng.org/main/trunk@8618 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 18 |
2 files changed, 12 insertions, 8 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 53e2bd08a8..9308be3ed8 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -1147,6 +1147,8 @@ bool facebook_client::channel() bool facebook_client::send_message(std::string message_recipient, std::string message_text, std::string *error_text, MessageMethod method)
{
+ ScopedLock s(send_message_lock_);
+
handle_entry("send_message");
http::response resp;
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index f7f3bc7100..ac53334fe5 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -262,6 +262,8 @@ int facebook_json_parser::parse_notifications(void *data, std::vector< facebook_ 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);
if (it != proto->facy.messages_ignore.end()) {
proto->debugLogA("????? Ignoring duplicit/sent message\n%s", text.c_str());
@@ -353,6 +355,14 @@ void parseAttachments(FacebookProto *proto, std::string *message_text, JSONNODE int facebook_json_parser::parse_messages(void* data, std::vector< facebook_message* >* messages, std::vector< 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)
+ it = proto->facy.messages_ignore.erase(it);
+ else
+ ++it;
+ }
+
std::string jsonData = static_cast< std::string* >(data)->substr(9);
JSONNODE *root = json_parse(jsonData.c_str());
@@ -723,14 +733,6 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa continue;
}
- // remove 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)
- it = proto->facy.messages_ignore.erase(it);
- else
- ++it;
- }
-
json_delete(root);
return EXIT_SUCCESS;
}
|