summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2016-08-31 10:11:28 +0000
committerRobert Pösel <robyer@seznam.cz>2016-08-31 10:11:28 +0000
commitfc8bb06ec24197d50e695e5de657e7904d6ce597 (patch)
treec7d7d934d6e1aa51f4e4f52fdb95cee0d9a78f9d /protocols
parenta5a6c8afb1d68330dc1e112ca9bdb0e38c435ad8 (diff)
Facebook: Support loading videocall events from server
git-svn-id: http://svn.miranda-ng.org/main/trunk@17221 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/FacebookRM/src/json.cpp47
1 files changed, 42 insertions, 5 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index b8ad460442..f8cfb701d8 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -962,6 +962,8 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector<faceboo
messages->push_back(message);
}
else {
+ proto->debugLogA("!!! Unknown log type - %s", logType.c_str());
+
// TODO: check for other types, now we expect this is rename chat
if (!proto->m_enableChat)
continue;
@@ -1107,12 +1109,20 @@ int facebook_json_parser::parse_thread_messages(std::string *data, std::vector<
const JSONNode &filtered = (*it)["is_filtered_content"];
const JSONNode &is_unread = (*it)["is_unread"];
- if (!author || !body || !mid || !tid || !timestamp)
+ // Either there is "body" (for classic messages), or "log_message_type" and "log_message_body" (for log messages)
+ const JSONNode &log_type_ = (*it)["log_message_type"];
+ const JSONNode &log_body_ = (*it)["log_message_body"];
+ // const JSONNode &log_data_ = (*it)["log_message_data"]; // additional data for this log message
+ // e.g., for missed video calls - {"answered":false,"caller":"fbid:1234567890","callee":"fbid:123456789012345"}
+
+ if (!author || (!body && !log_body_) || !mid || !tid || !timestamp) {
+ proto->debugLogA("parse_thread_messages: ignoring message (%s) - missing attribute", mid.as_string().c_str());
continue;
+ }
std::string thread_id = tid.as_string();
std::string message_id = mid.as_string();
- std::string message_text = body.as_string();
+ std::string message_text = body ? body.as_string() : log_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(":"); // strip "fbid:" prefix
@@ -1126,8 +1136,10 @@ int facebook_json_parser::parse_thread_messages(std::string *data, std::vector<
message_text = Translate("This message is no longer available, because it was marked as abusive or spam.");
message_text = utils::text::trim(utils::text::slashu_to_utf8(message_text), true);
- if (message_text.empty())
+ if (message_text.empty()) {
+ proto->debugLogA("parse_thread_messages: ignoring message (%s) - empty message text", mid.as_string().c_str());
continue;
+ }
bool isUnread = is_unread.as_bool();
@@ -1160,6 +1172,16 @@ int facebook_json_parser::parse_thread_messages(std::string *data, std::vector<
continue;
}
+ if (log_type_) {
+ std::string log_type = log_type_.as_string();
+ if (log_type == "log:video-call") {
+ message.type = CALL;
+ }
+ else {
+ proto->debugLogA("parse_thread_messages: unknown message log type (%s) - %s", mid.as_string().c_str(), log_type.c_str());
+ }
+ }
+
messages->push_back(message);
}
@@ -1194,7 +1216,12 @@ int facebook_json_parser::parse_history(std::string *data, std::vector< facebook
const JSONNode &filtered = (*it)["is_filtered_content"];
const JSONNode &is_unread = (*it)["is_unread"];
- if (!author || !body || !mid || !tid || !timestamp) {
+ // Either there is "body" (for classic messages), or "log_message_type" and "log_message_body" (for log messages)
+ const JSONNode &log_type_ = (*it)["log_message_type"];
+ const JSONNode &log_body_ = (*it)["log_message_body"];
+ // const JSONNode &log_data_ = (*it)["log_message_data"];
+
+ if (!author || (!body && !log_body_) || !mid || !tid || !timestamp) {
proto->debugLogA("parse_history: ignoring message (%s) - missing attribute", mid.as_string().c_str());
continue;
}
@@ -1206,7 +1233,7 @@ int facebook_json_parser::parse_history(std::string *data, std::vector< facebook
std::string thread_id = tid.as_string();
std::string message_id = mid.as_string();
- std::string message_text = body.as_string();
+ std::string message_text = body ? body.as_string() : log_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(":"); // strip "fbid:" prefix
@@ -1235,6 +1262,16 @@ int facebook_json_parser::parse_history(std::string *data, std::vector< facebook
message.isChat = false;
message.user_id = other_user_id;
+ if (log_type_) {
+ std::string log_type = log_type_.as_string();
+ if (log_type == "log:video-call") {
+ message.type = CALL;
+ }
+ else {
+ proto->debugLogA("parse_history: unknown message log type (%s) - %s", mid.as_string().c_str(), log_type.c_str());
+ }
+ }
+
messages->push_back(message);
}