summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2016-09-04 14:05:00 +0000
committerRobert Pösel <robyer@seznam.cz>2016-09-04 14:05:00 +0000
commit3dd0a1f40f3234973f41ed96d7d4890a560d95da (patch)
tree9b6e7e1a1516c7b7fb02bea8bb578600d282a9fc
parentabb7234475a08089b046b05de7a872d13491539b (diff)
Facebook: Fix determination whether some event is for chat or classic user
git-svn-id: http://svn.miranda-ng.org/main/trunk@17251 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/FacebookRM/src/json.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 310a61b0aa..80ee795daa 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -534,6 +534,7 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector<faceboo
const JSONNode &body = msg["body"];
// looks like there is either "tid" or "other_user_fbid" (or both)
+ const JSONNode &other_user_fbid_ = msg["other_user_fbid"];
const JSONNode &tid = msg["tid"];
const JSONNode &mid = msg["mid"];
const JSONNode &timestamp = msg["timestamp"];
@@ -549,8 +550,8 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector<faceboo
std::string message_id = mid.as_string();
std::string message_text = body.as_string();
- std::string thread_id = tid.as_string();
- std::string other_user_id = msg["other_user_fbid"].as_string();
+ std::string thread_id = tid ? tid.as_string() : "";
+ std::string other_user_id = other_user_fbid_ ? other_user_fbid_.as_string() : "";
// Process attachements and stickers
parseAttachments(proto, &message_text, msg, other_user_id, true);
@@ -1001,6 +1002,7 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector<faceboo
const JSONNode &log_body_ = action_["log_message_body"];
const JSONNode &log_data_ = action_["log_message_data"];
const JSONNode &log_type_ = action_["log_message_type"];
+ const JSONNode &other_user_fbid_ = action_["other_user_fbid"];
if (!author || !log_data_ || !log_body_ || !thread_id_ || !log_type_)
continue;
@@ -1008,7 +1010,7 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector<faceboo
std::string logType = log_type_.as_string();
std::string message_text = log_body_.as_string();
- std::string other_user_id = action_["other_user_fbid"].as_string();
+ std::string other_user_id = other_user_fbid_ ? other_user_fbid_.as_string() : "";
std::string message_id = action_["message_id"].as_string();
std::string author_id = author.as_string();
@@ -1017,7 +1019,7 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector<faceboo
author_id = author_id.substr(pos + 1);
facebook_message message;
- message.isChat = other_user_id.empty(); // FIXME: Determine whether this is chat or contact event
+ message.isChat = other_user_id.empty();
message.isUnread = true;
message.isIncoming = (author_id != proto->facy.self_.user_id);
message.message_text = message_text;