diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-05-29 16:27:54 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-05-29 16:27:54 +0000 |
commit | a1f316e4ddfc1c9c731688d1989d1f32a98261dd (patch) | |
tree | fe9b00d6737f79891612c77b53b08b49327fe7c3 /protocols/FacebookRM | |
parent | 672727906d73b5ad2fe5efe497586db655709a90 (diff) |
Facebook: Final fix for receiving messages as read/unread
git-svn-id: http://svn.miranda-ng.org/main/trunk@9353 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 60 | ||||
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 2 |
2 files changed, 24 insertions, 38 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 874d0e6f16..fa021936d2 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -501,39 +501,25 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa if (message_text.empty())
continue;
+ facebook_message* message = new facebook_message();
+ message->isUnread = true;
+ message->isIncoming = (id != proto->facy.self_.user_id);
+ message->message_text = message_text;
+ message->time = utils::time::fix_timestamp(json_as_float(timestamp));
+ message->user_id = id;
+ message->message_id = message_id;
+ message->sender_name = utils::text::special_expressions_decode(utils::text::slashu_to_utf8(json_as_pstring(sender_name))); // TODO: or if not incomming use my own name from facy.self_ ?
+ message->thread_id = json_as_pstring(tid); // TODO: or if not incomming use my own id from facy.self_ ?
+
JSONNODE *gthreadinfo = json_get(msg, "group_thread_info");
- if (gthreadinfo != NULL) {
- // Multi-user message
- facebook_message* message = new facebook_message();
-
- message->isChat = true;
- message->isUnread = true;
- message->isIncoming = (id != proto->facy.self_.user_id);
- message->message_text = message_text;
- message->sender_name = utils::text::special_expressions_decode(utils::text::slashu_to_utf8(json_as_pstring(sender_name))); // TODO: or if not incomming use my own name from facy.self_ ?
- message->time = utils::time::fix_timestamp(json_as_float(timestamp));
- message->thread_id = json_as_pstring(tid); // TODO: or if not incomming use my own id from facy.self_ ?
- message->user_id = id;
- message->message_id = message_id;
-
- messages->push_back(message);
- }
- else {
- // Standard message
- facebook_message* message = new facebook_message();
-
- message->isChat = false;
- message->isUnread = true;
- message->isIncoming = (id != proto->facy.self_.user_id);
- message->message_text = message_text;
- message->sender_name = message->isIncoming ? utils::text::special_expressions_decode(utils::text::slashu_to_utf8(json_as_pstring(sender_name))) : "";
- message->time = utils::time::fix_timestamp(json_as_float(timestamp));
- message->thread_id = json_as_pstring(tid);
- message->user_id = message->isIncoming ? id : proto->ThreadIDToContactID(message->thread_id); // TODO: Check if we have contact with this user_id in friendlist and otherwise do something different?
- message->message_id = message_id;
-
- messages->push_back(message);
+ message->isChat = (gthreadinfo != NULL);
+
+ if (!message->isChat && !message->isIncoming) {
+ message->sender_name = "";
+ message->user_id = proto->ThreadIDToContactID(message->thread_id); // TODO: Check if we have contact with this user_id in friendlist and otherwise do something different?
}
+
+ messages->push_back(message);
}
} else if (t == "notification_json") {
// event notification
@@ -844,6 +830,7 @@ int facebook_json_parser::parse_thread_messages(void* data, std::vector< faceboo JSONNODE *timestamp = json_get(it, "timestamp");
JSONNODE *filtered = json_get(it, "is_filtered_content");
JSONNODE *folder = json_get(it, "folder");
+ JSONNODE *is_unread = json_get(it, "is_unread");
if (author == NULL || body == NULL || mid == NULL || tid == NULL || timestamp == NULL)
continue;
@@ -877,6 +864,11 @@ int facebook_json_parser::parse_thread_messages(void* data, std::vector< faceboo message->thread_id = thread_id;
message->message_id = message_id;
message->isIncoming = (author_id != proto->facy.self_.user_id);
+ message->isUnread = (is_unread != NULL && json_as_bool(is_unread));
+
+ // Ignore read messages if we want only unread messages
+ if (unreadOnly && !message->isUnread)
+ continue;
std::map<std::string, facebook_chatroom*>::iterator iter = chatrooms->find(thread_id);
if (iter != chatrooms->end()) {
@@ -885,12 +877,6 @@ int facebook_json_parser::parse_thread_messages(void* data, std::vector< faceboo message->user_id = author_id;
} else {
// this is standard message
-
- // Ignore read messages if we want only unread messages
- JSONNODE *is_unread = json_get(it, "is_unread");
- if (unreadOnly && (is_unread == NULL || !json_as_bool(is_unread)))
- continue;
-
message->isChat = false;
std::map<std::string, std::string>::iterator iter = thread_ids.find(thread_id);
if (iter != thread_ids.end()) {
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index d57ae2d838..91e0ad3bf7 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -652,7 +652,7 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, boo dbei.flags = DBEF_UTF; if (!messages[i]->isIncoming) - dbei.flags |= DBEF_SENT | DBEF_READ; // sent messages are always read + dbei.flags |= DBEF_SENT; if (!messages[i]->isUnread) dbei.flags |= DBEF_READ; |