summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/json.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2016-09-01 21:44:49 +0000
committerRobert Pösel <robyer@seznam.cz>2016-09-01 21:44:49 +0000
commit73b4dd7987338cbb605e98505f21a16062663aae (patch)
treee30a34081877f7fb6a9cc55fd099e71b730b1fc6 /protocols/FacebookRM/src/json.cpp
parent756ce057cf3aecb1220daebadb3f728f51ef5b5e (diff)
Facebook: Set users that were active more than 15 minutes ago as offline; version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@17241 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/json.cpp')
-rw-r--r--protocols/FacebookRM/src/json.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 493569346f..71d706a4e1 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -754,6 +754,8 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector<faceboo
if (!buddyList)
continue;
+ time_t offlineThreshold = time(NULL) - 15 * 60; // contacts last active more than 15 minutes will be marked offline
+
for (auto itNodes = buddyList.begin(); itNodes != buddyList.end(); ++itNodes) {
std::string id = (*itNodes).name();
@@ -796,6 +798,12 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector<faceboo
else
proto->delSetting(hContact, "LastActiveTS");
}
+
+ // Set users inactive for too long as offline
+ if (last_active > 0 && last_active < offlineThreshold) {
+ if (proto->getWord(hContact, "Status", 0) != ID_STATUS_OFFLINE)
+ proto->setWord(hContact, "Status", ID_STATUS_OFFLINE);
+ }
}
// Probably means client: guess 0 = web, 8 = messenger, 10 = something else?
@@ -829,6 +837,8 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector<faceboo
if (!overlay)
continue;
+ time_t offlineThreshold = time(NULL) - 15 * 60; // contacts last active more than 15 minutes will be marked offline
+
for (auto itNodes = overlay.begin(); itNodes != overlay.end(); ++itNodes) {
std::string id = (*itNodes).name();
@@ -887,20 +897,16 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector<faceboo
status = ID_STATUS_OFFLINE;
}
- if (proto->getWord(hContact, "Status", 0) != status)
- proto->setWord(hContact, "Status", status);
-
-
- if (la_ && status != ID_STATUS_ONLINE) {
+ if (la_ /*&& status != ID_STATUS_ONLINE*/) {
time_t last_active = utils::time::from_string(la_.as_string());
// we should set IdleTS only when contact is IDLE, or OFFLINE
- if (proto->getDword(hContact, "IdleTS", 0) != last_active) {
- if (/*(fbu->idle || status == ID_STATUS_OFFLINE) &&*/ last_active > 0)
- proto->setDword(hContact, "IdleTS", last_active);
- else
- proto->delSetting(hContact, "IdleTS");
- }
+ //if (proto->getDword(hContact, "IdleTS", 0) != last_active) {
+ // if (/*(fbu->idle || status == ID_STATUS_OFFLINE) &&*/ last_active > 0)
+ // proto->setDword(hContact, "IdleTS", last_active);
+ // else
+ // proto->delSetting(hContact, "IdleTS");
+ //}
/*if (proto->getDword(hContact, "LastActiveTS", 0) != last_active) {
if (last_active > 0)
@@ -908,11 +914,18 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector<faceboo
else
proto->delSetting(hContact, "LastActiveTS");
}*/
+
+ // Set users inactive for too long as offline
+ if (last_active > 0 && last_active < offlineThreshold)
+ status = ID_STATUS_OFFLINE;
}
else {
proto->delSetting(hContact, "IdleTS");
}
+ if (proto->getWord(hContact, "Status", 0) != status)
+ proto->setWord(hContact, "Status", status);
+
if (s_) {
// what to do with this?
}