summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2015-02-07 08:43:54 +0000
committerRobert Pösel <robyer@seznam.cz>2015-02-07 08:43:54 +0000
commitb59a7efc33992c608a22af334cb6de3bb7dbc339 (patch)
tree9a8eddc6f8cdeac858bec78c51157bfaad2ff186
parent9fe7b9187d30041071ceebb4daf69cca38900b09 (diff)
Facebook: Show notification when friendship request is accepted (fix for recent FB changes)
git-svn-id: http://svn.miranda-ng.org/main/trunk@12038 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/FacebookRM/src/json.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 832e4d80d2..f47a1a0528 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -3,7 +3,7 @@
Facebook plugin for Miranda Instant Messenger
_____________________________________________
-Copyright � 2009-11 Michal Zelinka, 2011-15 Robert P�sel
+Copyright © 2009-11 Michal Zelinka, 2011-15 Robert Pösel
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -614,6 +614,34 @@ int facebook_json_parser::parse_messages(std::string *data, std::vector< faceboo
}
}
}
+ else if (t == "m_notification") {
+ JSONNODE *data = json_get(it, "data");
+ if (data == NULL)
+ continue;
+
+ JSONNODE *appId_ = json_get(data, "app_id");
+ JSONNODE *type_ = json_get(data, "type");
+
+ if ((appId_ && json_as_pstring(appId_) == "2356318349") || (type_ && json_as_pstring(type_) == "friend_confirmed")) {
+ // Friendship notifications
+
+ JSONNODE *body_ = json_get(data, "body");
+ JSONNODE *html_ = (body_ ? json_get(body_, "__html") : NULL);
+
+ JSONNODE *href_ = json_get(data, "href");
+ JSONNODE *unread_ = json_get(data, "unread");
+ JSONNODE *alertId_ = json_get(data, "alert_id");
+
+ if (html_ == NULL || href_ == NULL || unread_ == NULL || json_as_int(unread_) == 0)
+ continue;
+
+ std::string text = utils::text::remove_html(utils::text::slashu_to_utf8(json_as_pstring(html_)));
+ std::string url = json_as_pstring(href_);
+ std::string alert_id = (alertId_ ? json_as_pstring(alertId_) : "");
+
+ proto->NotifyEvent(proto->m_tszUserName, ptrT(mir_utf8decodeT(text.c_str())), NULL, FACEBOOK_EVENT_FRIENDSHIP, &url, alert_id.empty() ? NULL : &alert_id);
+ }
+ }
else if (t == "typ") {
// chat typing notification