summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/process.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2016-09-04 14:04:58 +0000
committerRobert Pösel <robyer@seznam.cz>2016-09-04 14:04:58 +0000
commitabb7234475a08089b046b05de7a872d13491539b (patch)
tree351459b322cbb09197225b399042ba5d3dfc7a52 /protocols/FacebookRM/src/process.cpp
parent1cfb77837fef9854796ee06929caa673fd3e6a6b (diff)
Facebook: Handle unsubscribe events in chat; improve also subscribe event
git-svn-id: http://svn.miranda-ng.org/main/trunk@17250 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/process.cpp')
-rw-r--r--protocols/FacebookRM/src/process.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index 6e678e6ca7..a2b533cda9 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -893,6 +893,7 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message> &messages, boo
UpdateChat(thread_id.c_str(), NULL, NULL, msg.message_text.c_str());
break;
case SUBSCRIBE:
+ case UNSUBSCRIBE:
{
UpdateChat(thread_id.c_str(), NULL, NULL, msg.message_text.c_str());
@@ -900,26 +901,27 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message> &messages, boo
utils::text::explode(msg.data, ";", &ids);
for (std::vector<std::string>::size_type k = 0; k < ids.size(); k++)
{
- if (fbc->participants.find(ids[k]) != fbc->participants.end()) {
- continue; // We have this participant in chatroom already
+ auto jt = fbc->participants.find(ids[k]);
+ 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];
+
+ // 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]);
+ }
+ if (jt != fbc->participants.end()) {
+ if (msg.type == SUBSCRIBE)
+ AddChatContact(thread_id.c_str(), jt->second, msg.isUnread);
+ else
+ RemoveChatContact(thread_id.c_str(), jt->second.user_id.c_str(), jt->second.nick.c_str());
}
- // 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.user_id = ids[k];
-
- // 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;
case THREAD_NAME:
// proto->RenameChat(thread_id.c_str(), msg.data.c_str()); // this don't work, why?
setStringUtf(hChatContact, FACEBOOK_KEY_NICK, msg.data.c_str());