diff options
Diffstat (limited to 'protocols/FacebookRM/src')
-rw-r--r-- | protocols/FacebookRM/src/client.h | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 45 | ||||
-rw-r--r-- | protocols/FacebookRM/src/json.h | 60 | ||||
-rw-r--r-- | protocols/FacebookRM/src/main.cpp | 1 | ||||
-rw-r--r-- | protocols/FacebookRM/src/messages.cpp | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/proto.cpp | 4 | ||||
-rw-r--r-- | protocols/FacebookRM/src/requests/contacts.h | 8 | ||||
-rw-r--r-- | protocols/FacebookRM/src/requests/history.h | 70 | ||||
-rw-r--r-- | protocols/FacebookRM/src/version.h | 1 |
9 files changed, 27 insertions, 166 deletions
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h index 8d80ea72ef..4d7fe6ef1e 100644 --- a/protocols/FacebookRM/src/client.h +++ b/protocols/FacebookRM/src/client.h @@ -161,7 +161,7 @@ public: }
__inline const char *__rev() {
- return "3496859"; // FIXME: Some version of communication protocol? This version is from 3.12.2017
+ return "2828561"; // FIXME: Some version of communication protocol? This version is from 12.2.2017
}
////////////////////////////////////////////////////////////
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index aabf0823f1..2deb45172f 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -282,11 +282,6 @@ void parseAttachments(FacebookProto *proto, std::string *message_text, const JSO for (auto itAttachment = attachments_.begin(); itAttachment != attachments_.end(); ++itAttachment) { const JSONNode &attach_ = legacy ? (*itAttachment) : (*itAttachment)["mercury"]; - // FIXME: FB now doesn't have single "attach_type" node that we can check, but it's separated in different nodes. So we must check existence of different nodes for different types of attachments (or iterate over all existing nodes and check if some attachment node exists) - const JSONNode sticker_ = attach_["sticker_attachment"]; - const JSONNode blob_ = attach_["blob_attachment"]; - const JSONNode todo_ = attach_["todo"]; - type = attach_["attach_type"].as_string(); // "sticker", "photo", "file", "share", "animated_image", "video" if (type == "photo") { @@ -1462,43 +1457,3 @@ int facebook_json_parser::parse_messages_count(std::string *data, int *messagesC return EXIT_SUCCESS; } - -///////////////////////////////////////////////////////////////////////////////////////// - -JSONNode& operator<<(JSONNode &json, const NULL_PARAM ¶m) -{ - json.push_back(JSONNode(param.szName, nullptr)); - return json; -} - -JSONNode& operator<<(JSONNode &json, const JSON_PARAM ¶m) -{ - json.push_back(JSONNode(param.szName, param.node)); - return json; -} - -JSONNode& operator<<(JSONNode &json, const INT_PARAM ¶m) -{ - json.push_back(JSONNode(param.szName, param.iValue)); - return json; -} - -JSONNode& operator<<(JSONNode &json, const BOOL_PARAM ¶m) -{ - json.push_back(JSONNode(param.szName, param.bValue)); - return json; -} - -JSONNode& operator<<(JSONNode &json, const CHAR_PARAM ¶m) -{ - json.push_back(JSONNode(param.szName, param.szValue)); - return json; -} - -JSONNode& operator<<(JSONNode &json, const WCHAR_PARAM ¶m) -{ - json.push_back(JSONNode(param.szName, ptrA(mir_utf8encodeW(param.wszValue)).get())); - return json; -} - -/////////////////////////////////////////////////////////////////////////////////////////
\ No newline at end of file diff --git a/protocols/FacebookRM/src/json.h b/protocols/FacebookRM/src/json.h index 27dbbf1710..d62666a66d 100644 --- a/protocols/FacebookRM/src/json.h +++ b/protocols/FacebookRM/src/json.h @@ -47,63 +47,3 @@ public: this->proto = proto;
}
};
-
-struct PARAM
-{
- LPCSTR szName;
- __forceinline PARAM(LPCSTR _name) : szName(_name)
- {}
-};
-
-struct NULL_PARAM : public PARAM
-{
- __forceinline NULL_PARAM(LPCSTR _name) : PARAM(_name)
- {}
-};
-
-struct JSON_PARAM : public PARAM
-{
- JSONNode node;
- __forceinline JSON_PARAM(LPCSTR _name, JSONNode _node) :
- PARAM(_name), node(_node)
- {}
-};
-
-struct BOOL_PARAM : public PARAM
-{
- bool bValue;
- __forceinline BOOL_PARAM(LPCSTR _name, bool _value) :
- PARAM(_name), bValue(_value)
- {}
-};
-
-struct INT_PARAM : public PARAM
-{
- int iValue;
- __forceinline INT_PARAM(LPCSTR _name, int _value) :
- PARAM(_name), iValue(_value)
- {}
-};
-
-struct CHAR_PARAM : public PARAM
-{
- LPCSTR szValue;
- __forceinline CHAR_PARAM(LPCSTR _name, LPCSTR _value) :
- PARAM(_name), szValue(_value)
- {}
-};
-
-struct WCHAR_PARAM : public PARAM
-{
- LPCWSTR wszValue;
- __forceinline WCHAR_PARAM(LPCSTR _name, LPCWSTR _value) :
- PARAM(_name), wszValue(_value)
- {}
-};
-
-JSONNode& operator<<(JSONNode &json, const NULL_PARAM ¶m);
-JSONNode& operator<<(JSONNode &json, const JSON_PARAM ¶m);
-JSONNode& operator<<(JSONNode &json, const INT_PARAM ¶m);
-JSONNode& operator<<(JSONNode &json, const BOOL_PARAM ¶m);
-JSONNode& operator<<(JSONNode &json, const CHAR_PARAM ¶m);
-JSONNode& operator<<(JSONNode &json, const WCHAR_PARAM ¶m);
diff --git a/protocols/FacebookRM/src/main.cpp b/protocols/FacebookRM/src/main.cpp index 24ed75eeb1..fbf0eef6df 100644 --- a/protocols/FacebookRM/src/main.cpp +++ b/protocols/FacebookRM/src/main.cpp @@ -37,7 +37,6 @@ PLUGININFOEX pluginInfo = { PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
__DESCRIPTION,
__AUTHOR,
- __AUTHOREMAIL,
__COPYRIGHT,
__AUTHORWEB,
UNICODE_AWARE,
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp index ea3ad14b32..941f7f0327 100644 --- a/protocols/FacebookRM/src/messages.cpp +++ b/protocols/FacebookRM/src/messages.cpp @@ -204,7 +204,7 @@ void FacebookProto::StickerAsSmiley(std::string sticker, const std::string &url, if (facy.loading_history) return; - std::string b64 = ptrA(mir_base64_encode((PBYTE)sticker.c_str(), (unsigned)sticker.length())); + std::string b64 = ptrA(mir_base64_encode(sticker.c_str(), sticker.length())); b64 = utils::url::encode(b64); std::wstring filename = GetAvatarFolder() + L"\\stickers\\"; diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index c4f33dd222..17698d6e29 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -383,8 +383,8 @@ int FacebookProto::OnIdleChanged(WPARAM, LPARAM lParam) if (idle) { // User started being idle - MIRANDA_IDLE_INFO mii = { sizeof(mii) }; - CallService(MS_IDLE_GETIDLEINFO, 0, (LPARAM)&mii); + MIRANDA_IDLE_INFO mii; + Idle_GetInfo(mii); // Compute time when user really became idle m_idleTS = time(nullptr) - mii.idleTime * 60; diff --git a/protocols/FacebookRM/src/requests/contacts.h b/protocols/FacebookRM/src/requests/contacts.h index 960fb269b3..8fa60fced8 100644 --- a/protocols/FacebookRM/src/requests/contacts.h +++ b/protocols/FacebookRM/src/requests/contacts.h @@ -36,7 +36,7 @@ public: // getting info about particular friend -// revised 3.12.2017 +// revised 17.8.2016 class UserInfoRequest : public HttpRequest { public: @@ -60,11 +60,7 @@ public: << CHAR_VALUE("__rev", fc->__rev()) << "__a=1" << "__pc=PHASED:DEFAULT" - << "__be=1" - << "jazoest=" - << "__spin_r=" - << "__spin_b=" - << "__spin_t="; + << "__be=-1"; } }; diff --git a/protocols/FacebookRM/src/requests/history.h b/protocols/FacebookRM/src/requests/history.h index 88890a0f8e..9ac3d52168 100644 --- a/protocols/FacebookRM/src/requests/history.h +++ b/protocols/FacebookRM/src/requests/history.h @@ -24,20 +24,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define _FACEBOOK_REQUEST_HISTORY_H_ // getting thread info and messages -// revised 3.12.2017 +// revised 17.8.2016 class ThreadInfoRequest : public HttpRequest { public: // Request only messages history ThreadInfoRequest(facebook_client *fc, bool isChat, const char *id, int offset, const char *timestamp, int limit) : - HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/api/graphqlbatch/") + HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/thread_info.php") { - setCommonBody(fc); + Url + << "dpr=1"; - // 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. + setCommonBody(fc); - //const char *type = isChat ? "thread_fbids" : "user_ids"; + const char *type = isChat ? "thread_fbids" : "user_ids"; std::string id_ = id; // FIXME: Rewrite this without std::string... if (isChat) { // NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId @@ -46,38 +46,6 @@ public: } ptrA idEncoded(mir_urlEncode(id_.c_str())); - - JSONNode root, o0, query_params; - - int before = -1; - - query_params - << CHAR_PARAM("id", id_) // TODO: Do I have to encode the id? And remove that first "id." at the begin as we do above? - << INT_PARAM("message_limit", limit) - << INT_PARAM("load_messages", 1) - << BOOL_PARAM("load_read_receipts", false); - - if (before != -1) { - query_params << INT_PARAM("before", before); - } - else { - query_params << NULL_PARAM("before"); - } - - o0 - << CHAR_PARAM("doc_id", id) - << JSON_PARAM("query_params", query_params); - - root << JSON_PARAM("o0", o0); - - Body - << "batch_name=MessengerGraphQLThreadFetcherRe" - << CHAR_VALUE("queries", root.write().c_str()); - - // example request data we need to send: { "o0":{"doc_id":"456789456123","query_params" : {"id":"123456789","message_limit" : 20,"load_messages" : 1,"load_read_receipts" : false,"before" : null}} } - - - /* //if (loadMessages) { // Grrr, offset doesn't work at all, we need to use timestamps to get back in history... // And we don't know, what's timestamp of first message, so we need to get from latest to oldest @@ -87,7 +55,7 @@ public: << CMStringA(::FORMAT, "%s[offset]=%i", begin.c_str(), offset).c_str() << CMStringA(::FORMAT, "%s[timestamp]=%s", begin.c_str(), timestamp).c_str() << CMStringA(::FORMAT, "%s[limit]=%i", begin.c_str(), limit).c_str(); - //}*/ + //} /*if (loadThreadInfo) { data += "&threads[" + type + "][0]=" + idEncoded; @@ -96,8 +64,11 @@ public: // Request only thread info // TODO: Make it array of ids ThreadInfoRequest(facebook_client *fc, bool isChat, const char *id) : - HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/api/graphqlbatch/") + HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/thread_info.php") { + Url + << "dpr=1"; + setCommonBody(fc); const char *type = isChat ? "thread_fbids" : "user_ids"; @@ -115,8 +86,11 @@ public: // Request both thread info and messages for single contact/chat ThreadInfoRequest(facebook_client *fc, bool isChat, const char *id, int limit) : - HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/api/graphqlbatch/") + HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/thread_info.php") { + Url + << "dpr=1"; + setCommonBody(fc); const char *type = isChat ? "thread_fbids" : "user_ids"; @@ -142,8 +116,11 @@ public: // Request both thread info and messages for more threads ThreadInfoRequest(facebook_client *fc, const LIST<char> &ids, int offset, int limit) : - HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/api/graphqlbatch/") + HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/thread_info.php") { + Url + << "dpr=1"; + setCommonBody(fc); for (int i = 0; i < ids.getCount(); i++) { @@ -169,6 +146,7 @@ private: void setCommonBody(facebook_client *fc) { Body + << "client=mercury" << CHAR_VALUE("__user", fc->self_.user_id.c_str()) << CHAR_VALUE("__dyn", fc->__dyn()) << CHAR_VALUE("__req", fc->__req()) @@ -177,11 +155,7 @@ private: << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str()) << "__a=1" << "__pc=PHASED:DEFAULT" - << "__be=1" - << "jazoest=" - << "__spin_r=" - << "__spin_b=" - << "__spin_t="; + << "__be=-1"; } }; @@ -209,8 +183,6 @@ public: << "__a=1" << "__pc=PHASED:DEFAULT" << "__be=-1"; - - //queries={"o0":{"doc_id":"2003371749678240","query_params":{"limit":99,"before":null,"tags":["PENDING","unread"],"includeDeliveryReceipts":true,"includeSeqID":false}}} } }; diff --git a/protocols/FacebookRM/src/version.h b/protocols/FacebookRM/src/version.h index 1299f09155..08b34f8856 100644 --- a/protocols/FacebookRM/src/version.h +++ b/protocols/FacebookRM/src/version.h @@ -9,6 +9,5 @@ #define __FILENAME "Facebook.dll" #define __DESCRIPTION "Facebook protocol support for Miranda NG." #define __AUTHOR "Michal Zelinka, Robert Pösel" -#define __AUTHOREMAIL "robyer@seznam.cz" #define __AUTHORWEB "https://miranda-ng.org/p/Facebook/" #define __COPYRIGHT "© 2011-17 Robert Pösel, 2009-11 Michal Zelinka" |