summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/history.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-01-08 20:15:22 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-01-08 20:15:22 +0300
commit968eceb522b9dc380a4922e2f6b08857dec83bf4 (patch)
tree62214fa8eb79b103dd1703740189d50e98c128cf /protocols/FacebookRM/src/history.cpp
parent1c6bcb36c8b19d6a40e23dc9a71944e48bb67295 (diff)
Facebook: less RTTI, less useless data
Diffstat (limited to 'protocols/FacebookRM/src/history.cpp')
-rw-r--r--protocols/FacebookRM/src/history.cpp81
1 files changed, 44 insertions, 37 deletions
diff --git a/protocols/FacebookRM/src/history.cpp b/protocols/FacebookRM/src/history.cpp
index e1abb1dbeb..d5193f3bdf 100644
--- a/protocols/FacebookRM/src/history.cpp
+++ b/protocols/FacebookRM/src/history.cpp
@@ -22,18 +22,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-ThreadInfoRequest::ThreadInfoRequest(facebook_client *fc, bool isChat, const char *id, const char* timestamp, int limit) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/api/graphqlbatch/")
+HttpRequest* facebook_client::threadInfoRequest(bool isChat, const char *id, const char* timestamp, int limit)
{
- setCommonBody(fc);
+ HttpRequest *p = new HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/api/graphqlbatch/");
- // FIXME: FB removed /ajax/mercury/thread_info requests and now all messaging stuff does through /api/graphqlbatch/ - all loading of threads, (unread) messages, list of contacts in groupchat, etc.
- // All these request must be rewritten to the new request. Preparation is below but unfinished.
+ p->Body
+ << CHAR_PARAM("batch_name", "MessengerGraphQLThreadFetcherRe")
+ << CHAR_PARAM("__user", self_.user_id.c_str())
+ << INT_PARAM("__a", 1)
+ << CHAR_PARAM("__dyn", __dyn())
+ << CHAR_PARAM("__req", __req())
+ << INT_PARAM("__be", 1)
+ << CHAR_PARAM("__pc", "PHASED:DEFAULT")
+ << CHAR_PARAM("__rev", __rev())
+ << CHAR_PARAM("fb_dtsg", dtsg_.c_str());
- //const char *type = isChat ? "thread_fbids" : "user_ids";
- std::string id_ = id; // FIXME: Rewrite this without std::string...
+ std::string id_ = id;
if (isChat) {
- // NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId
if (id_.substr(0, 3) == "id.")
id_ = id_.substr(3);
}
@@ -54,14 +59,26 @@ ThreadInfoRequest::ThreadInfoRequest(facebook_client *fc, bool isChat, const cha
o0 << CHAR_PARAM("doc_id", "1549485615075443") << JSON_PARAM("query_params", query_params);
root << JSON_PARAM("o0", o0);
- Body << CHAR_PARAM("queries", utils::url::encode(root.write()).c_str());
+ p->Body << CHAR_PARAM("queries", utils::url::encode(root.write()).c_str());
+
+ return p;
}
// Request both thread info and messages for more threads
-ThreadInfoRequest::ThreadInfoRequest(facebook_client *fc, const LIST<char> &ids, int offset, int limit) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/api/graphqlbatch/")
+HttpRequest* facebook_client::threadInfoRequest(const LIST<char> &ids, int offset, int limit)
{
- setCommonBody(fc);
+ HttpRequest *p = new HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/api/graphqlbatch/");
+
+ p->Body
+ << CHAR_PARAM("batch_name", "MessengerGraphQLThreadFetcherRe")
+ << CHAR_PARAM("__user", self_.user_id.c_str())
+ << INT_PARAM("__a", 1)
+ << CHAR_PARAM("__dyn", __dyn())
+ << CHAR_PARAM("__req", __req())
+ << INT_PARAM("__be", 1)
+ << CHAR_PARAM("__pc", "PHASED:DEFAULT")
+ << CHAR_PARAM("__rev", __rev())
+ << CHAR_PARAM("fb_dtsg", dtsg_.c_str());
for (int i = 0; i < ids.getCount(); i++) {
// NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId
@@ -72,44 +89,34 @@ ThreadInfoRequest::ThreadInfoRequest(facebook_client *fc, const LIST<char> &ids,
// Load messages
CMStringA begin(::FORMAT, "messages[%s][%s]", "thread_fbids", idEncoded);
- Body
+ p->Body
<< INT_PARAM(CMStringA(::FORMAT, "%s[offset]", begin.c_str()), offset)
<< INT_PARAM(CMStringA(::FORMAT, "%s[limit]", begin.c_str()), limit)
<< CHAR_PARAM(CMStringA(::FORMAT, "threads[%s][%i]", "thread_fbids", i), idEncoded);
}
-}
-void ThreadInfoRequest::setCommonBody(facebook_client *fc)
-{
- Body
- << CHAR_PARAM("batch_name", "MessengerGraphQLThreadFetcherRe")
- << CHAR_PARAM("__user", fc->self_.user_id.c_str())
- << INT_PARAM("__a", 1)
- << CHAR_PARAM("__dyn", fc->__dyn())
- << CHAR_PARAM("__req", fc->__req())
- << INT_PARAM("__be", 1)
- << CHAR_PARAM("__pc", "PHASED:DEFAULT")
- << CHAR_PARAM("__rev", fc->__rev())
- << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_PARAM("jazoest", "265816910476541027556899745586581711208287100122699749108");
+ return p;
}
-UnreadThreadsRequest::UnreadThreadsRequest(facebook_client *fc) :
- HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/unread_threads.php")
+HttpRequest* facebook_client::unreadThreadsRequest()
{
- Url << INT_PARAM("dpr", 1);
+ HttpRequest *p = new HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/unread_threads.php");
- Body
+ p->Url << INT_PARAM("dpr", 1);
+
+ p->Body
<< CHAR_PARAM("folders[0]", "inbox")
<< CHAR_PARAM("folders[1]", "other") // TODO: "other" is probably unused, and there is now "pending" instead
<< CHAR_PARAM("client", "mercury")
- << CHAR_PARAM("__user", fc->self_.user_id.c_str())
- << CHAR_PARAM("__dyn", fc->__dyn())
- << CHAR_PARAM("__req", fc->__req())
- << CHAR_PARAM("__rev", fc->__rev())
- << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_PARAM("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_PARAM("__user", self_.user_id.c_str())
+ << CHAR_PARAM("__dyn", __dyn())
+ << CHAR_PARAM("__req", __req())
+ << CHAR_PARAM("__rev", __rev())
+ << CHAR_PARAM("fb_dtsg", dtsg_.c_str())
+ << CHAR_PARAM("ttstamp", ttstamp_.c_str())
<< CHAR_PARAM("__pc", "PHASED:DEFAULT")
<< INT_PARAM("__a", 1)
<< INT_PARAM("__be", -1);
+
+ return p;
}