summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2015-08-29 16:28:30 +0000
committerRobert Pösel <robyer@seznam.cz>2015-08-29 16:28:30 +0000
commit8fa4648bf13000d7b81225400905cf884ab8730d (patch)
tree999917b112a9b4c0015e33d158230c4c22c824e6
parent930d0e7cfff760ba8650fa431b32b97f5a525754 (diff)
Facebook: Fix receiving messages on login / opening window
git-svn-id: http://svn.miranda-ng.org/main/trunk@15096 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/FacebookRM/src/json.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 59ca61e479..99cebe36a0 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -874,17 +874,19 @@ int facebook_json_parser::parse_thread_messages(std::string *data, std::vector<
std::map<std::string, std::string> thread_ids;
for (auto it = threads.begin(); it != threads.end(); ++it) {
const JSONNode &is_canonical_user = (*it)["is_canonical_user"];
- const JSONNode &canonical = (*it)["canonical_fbid"];
+ const JSONNode &thread_fbid = (*it)["thread_fbid"]; // alternatively there is "other_user_fbid" too
const JSONNode &thread_id = (*it)["thread_id"];
const JSONNode &name = (*it)["name"];
//const JSONNode &message_count = (*it)["message_count");
//const JSONNode &unread_count = (*it)["unread_count"); // TODO: use it to check against number of loaded messages... but how?
const JSONNode &folder = (*it)["folder"];
- if (!canonical || !thread_id)
+ if (!thread_fbid || !thread_id) {
+ proto->debugLogA("!!! Missing thread_fbid/thread_id");
continue;
+ }
- std::string id = canonical.as_string();
+ std::string id = thread_fbid.as_string();
std::string tid = thread_id.as_string();
std::map<std::string, facebook_chatroom*>::iterator iter = chatrooms->find(tid);
@@ -919,6 +921,7 @@ int facebook_json_parser::parse_thread_messages(std::string *data, std::vector<
for (auto it = actions.begin(); it != actions.end(); ++it) {
const JSONNode &author = (*it)["author"];
const JSONNode &author_email = (*it)["author_email"];
+ const JSONNode &other_user_fbid = (*it)["other_user_fbid"];
const JSONNode &body = (*it)["body"];
const JSONNode &tid = (*it)["thread_id"];
const JSONNode &mid = (*it)["message_id"];
@@ -937,12 +940,13 @@ int facebook_json_parser::parse_thread_messages(std::string *data, std::vector<
std::string message_id = mid.as_string();
std::string message_text = body.as_string();
std::string author_id = author.as_string();
+ std::string other_user_id = other_user_fbid ? other_user_fbid.as_string() : "";
std::string::size_type pos = author_id.find(":");
if (pos != std::string::npos)
author_id = author_id.substr(pos + 1);
// Process attachements and stickers
- parseAttachments(proto, &message_text, *it, thread_id, ""); // FIXME: is here supported other_user_fbid ?
+ parseAttachments(proto, &message_text, *it, thread_id, other_user_id);
if (filtered.as_bool() && message_text.empty())
message_text = Translate("This message is no longer available, because it was marked as abusive or spam.");
@@ -978,6 +982,8 @@ int facebook_json_parser::parse_thread_messages(std::string *data, std::vector<
auto iter = thread_ids.find(thread_id);
if (iter != thread_ids.end())
message->user_id = iter->second; // TODO: Check if we have contact with this ID in friendlist and otherwise do something different?
+ else if (!other_user_id.empty())
+ message->user_id = other_user_id;
else {
delete message;
continue;