diff options
author | ikeblaster <ike@thez.info> | 2020-02-20 15:10:33 +0100 |
---|---|---|
committer | ikeblaster <ike@thez.info> | 2020-02-20 15:10:33 +0100 |
commit | 1ff0429a1eeb75f2d84ec89fd06a06acf9c0219b (patch) | |
tree | 097647944ff064f249d96e001154db6f4903ea3f /protocols/Facebook/src/server.cpp | |
parent | dc960c3a24a2c77fa7461dd6a154baa83a1c2c20 (diff) |
Facebook: group chat loading improvement
Loading only unarchived group chats, where user is still subscribed.
When thread_count limit is sent, response is sorted. Hardcoded to 40 threads - not ideal, since response contains also normal chats (those are skipped). Better solution proposed in TODO.
Diffstat (limited to 'protocols/Facebook/src/server.cpp')
-rw-r--r-- | protocols/Facebook/src/server.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp index fbff76af40..faa8032d7b 100644 --- a/protocols/Facebook/src/server.cpp +++ b/protocols/Facebook/src/server.cpp @@ -267,8 +267,10 @@ FacebookUser* FacebookProto::RefreshThread(CMStringW& wszId) { void FacebookProto::RefreshThreads() { + int threadsLimit = 40; + auto * pReq = CreateRequestGQL(FB_API_QUERY_THREADS); - JSONNode json; json << CHAR_PARAM("2", "true") << CHAR_PARAM("12", "false") << CHAR_PARAM("13", "false"); + JSONNode json; json << INT_PARAM("1", threadsLimit) << CHAR_PARAM("2", "true") << CHAR_PARAM("12", "false") << CHAR_PARAM("13", "false"); pReq << CHAR_PARAM("query_params", json.write().c_str()); pReq->CalcSig(); @@ -277,8 +279,12 @@ void FacebookProto::RefreshThreads() auto &root = reply.data()["viewer"]["message_threads"]; for (auto &n : root["nodes"]) { - RefreshThread(n); + if (n["is_group_thread"].as_bool() && n["is_viewer_subscribed"].as_bool() && !n["has_viewer_archived"].as_bool()) + RefreshThread(n); } + + // TODO: save timestamp of last message/action/... into DB + // TODO: lower threadsLimit to 10, load next pages if timestamp of last message is higher than timestamp in DB } } |