summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/json.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-06-10 18:22:59 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-06-10 18:23:05 +0300
commit725ee7bd32418048b1739c04ff6abf63fffab817 (patch)
tree807e5d16d9eb53910db1b1f3278bbd676b871bff /protocols/FacebookRM/src/json.cpp
parent8e2515105956ffde5915379348d7df94d4e3f06b (diff)
fixes #1978 (Facebook notification issue)
Diffstat (limited to 'protocols/FacebookRM/src/json.cpp')
-rw-r--r--protocols/FacebookRM/src/json.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 2ff53ff346..de642b4186 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -226,15 +226,18 @@ int FacebookProto::ParseNotifications(std::string *data, std::map< std::string,
if (!text_ || !state_ || state_.as_string() == "SEEN_AND_READ" || !time_)
continue;
- facebook_notification *notification = new facebook_notification();
-
- notification->id = id_.as_string();
-
// Fix notification ID
- std::string::size_type pos = notification->id.find(":");
+ std::string msgid = id_.as_string();
+ std::string::size_type pos = msgid.find(":");
if (pos != std::string::npos)
- notification->id = notification->id.substr(pos + 1);
+ msgid = msgid.substr(pos + 1);
+
+ // Skip duplicate notifications
+ if (notifications->find(msgid) != notifications->end())
+ continue;
+ facebook_notification *notification = new facebook_notification();
+ notification->id = msgid;
notification->link = url_.as_string();
notification->text = utils::text::html_entities_decode(utils::text::slashu_to_utf8(text_.as_string()));
notification->time = utils::time::from_string(time_.as_string());
@@ -242,12 +245,7 @@ int FacebookProto::ParseNotifications(std::string *data, std::map< std::string,
// Write notification to chatroom
UpdateNotificationsChatRoom(notification);
-
- // If it's unseen, remember it, otherwise forget it
- if (notifications->find(notification->id) == notifications->end())
- notifications->insert(std::make_pair(notification->id, notification));
- else
- delete notification;
+ notifications->insert(std::make_pair(notification->id, notification));
}
return EXIT_SUCCESS;