diff options
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/FacebookRM/src/entities.h | 28 | ||||
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 22 |
2 files changed, 27 insertions, 23 deletions
diff --git a/protocols/FacebookRM/src/entities.h b/protocols/FacebookRM/src/entities.h index 5b10bd53ee..3fd692a88d 100644 --- a/protocols/FacebookRM/src/entities.h +++ b/protocols/FacebookRM/src/entities.h @@ -77,11 +77,9 @@ struct chatroom_participant { std::string user_id; std::string nick; - ParticipantRole role; - bool is_former; - bool loaded; - - chatroom_participant() : loaded(false), is_former(false), role(ROLE_NONE) {} + ParticipantRole role = ROLE_NONE; + bool is_former = false; + bool loaded = false; }; struct facebook_chatroom @@ -89,17 +87,15 @@ struct facebook_chatroom std::string thread_id; std::wstring chat_name; std::map<std::string, chatroom_participant> participants; - bool can_reply; - bool is_archived; - bool is_subscribed; - bool read_only; - - facebook_chatroom(std::string thread_id) : thread_id(thread_id) { - this->can_reply = true; - this->is_archived = false; - this->is_subscribed = true; - this->read_only = false; - } + bool can_reply = true; + bool is_archived = false; + bool is_subscribed = true; + bool read_only = false; + int64_t tmp_msgid = 0; + + facebook_chatroom(std::string _thread_id) : + thread_id(_thread_id) + {} }; struct facebook_message diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index 0aa29b9639..c484fffd76 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -723,8 +723,7 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message> &messages, boo std::set<MCONTACT> *hChatContacts = new std::set<MCONTACT>(); - for (std::vector<facebook_message*>::size_type i = 0; i < messages.size(); i++) { - facebook_message &msg = messages[i]; + for (auto &msg : messages) { if (msg.isChat) { if (!m_enableChat) continue; @@ -795,24 +794,33 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message> &messages, boo case ADMIN_TEXT: UpdateChat(thread_id.c_str(), nullptr, nullptr, msg.message_text.c_str()); break; - case SUBSCRIBE: case UNSUBSCRIBE: + // this is our own request to leave the groupchat + if (_atoi64(msg.message_id.c_str()) == fbc->tmp_msgid) { + Chat_Terminate(m_szModuleName, _A2T(fbc->thread_id.c_str()), true); + facy.chat_rooms.erase(thread_id); + delete fbc; + break; + } + // fall through + + case SUBSCRIBE: UpdateChat(thread_id.c_str(), nullptr, nullptr, msg.message_text.c_str()); { std::vector<std::string> ids; utils::text::explode(msg.data, ";", &ids); - for (std::vector<std::string>::size_type k = 0; k < ids.size(); k++) { - auto jt = fbc->participants.find(ids[k]); + for (auto &id : ids) { + auto jt = fbc->participants.find(id); if (jt == fbc->participants.end()) { // We don't have this user there yet, so load info about him and then process event chatroom_participant participant; participant.is_former = (msg.type == UNSUBSCRIBE); - participant.user_id = ids[k]; + participant.user_id = id; // FIXME: Load info about all participants at once fbc->participants.insert(std::make_pair(participant.user_id, participant)); LoadParticipantsNames(fbc); - jt = fbc->participants.find(ids[k]); + jt = fbc->participants.find(id); } if (jt != fbc->participants.end()) { if (msg.type == SUBSCRIBE) |