From f19d5fcb4c2807387aa89649a3601658766e3755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Wed, 31 Aug 2016 10:11:34 +0000 Subject: Facebook: Improve handling users joining chatroom (fixes #1279) This commit makes them add to chat's user list and load their name too. git-svn-id: http://svn.miranda-ng.org/main/trunk@17223 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/FacebookRM/src/json.cpp | 24 ++++++++++++++++++++++++ protocols/FacebookRM/src/process.cpp | 27 ++++++++++++++++++--------- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 2c97a56b4a..a46fd08fb2 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -972,6 +972,14 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector &messages, boo if (jt != fbc->participants.end()) { name = jt->second.nick; } - else { - // TODO: Load info about this participant from server, and add it manually to participants list (maybe only if this is SUBSCRIBE type) - } switch (msg.type) { default: @@ -992,18 +989,30 @@ void FacebookProto::ReceiveMessages(std::vector &messages, boo UpdateChat(thread_id.c_str(), NULL, NULL, msg.message_text.c_str()); break; case SUBSCRIBE: - // TODO: We must get data with list of added users (their ids) from json to work properly, so for now we just print it as admin message + { UpdateChat(thread_id.c_str(), NULL, NULL, msg.message_text.c_str()); - /*if (jt == fbc->participants.end()) { + + std::vector ids; + utils::text::explode(msg.data, ";", &ids); + for (std::vector::size_type i = 0; i < ids.size(); i++) + { + if (fbc->participants.find(ids[i]) != fbc->participants.end()) { + continue; // We have this participant in chatroom already + } // We don't have this user there yet, so load info about him and then add him chatroom_participant participant; participant.is_former = false; - participant.loaded = false; - participant.nick = msg.data; - participant.user_id = msg.data; + participant.user_id = ids[i]; + + // FIXME: Load info about all participants at once + fbc->participants.insert(std::make_pair(participant.user_id, participant)); + LoadParticipantsNames(fbc); + AddChatContact(thread_id.c_str(), participant, msg.isUnread); - }*/ + } + break; + } case UNSUBSCRIBE: RemoveChatContact(thread_id.c_str(), msg.user_id.c_str(), name.c_str()); break; -- cgit v1.2.3