summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/requests/messages.h
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-01-03 13:41:49 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-01-03 13:41:49 +0300
commitf524101c14374c2efd1318f9d9085b1216b69620 (patch)
tree1a556fda936976e854ce14a42cb801e21829dd67 /protocols/FacebookRM/src/requests/messages.h
parentd5d5b3f352e0cc2601013950cd48d5aad5c73baa (diff)
Facebook:
- switch to the kernel parameter types; - strong parameters typization (also produces more compact code) - fixed timeline notifications - version bump
Diffstat (limited to 'protocols/FacebookRM/src/requests/messages.h')
-rw-r--r--protocols/FacebookRM/src/requests/messages.h112
1 files changed, 53 insertions, 59 deletions
diff --git a/protocols/FacebookRM/src/requests/messages.h b/protocols/FacebookRM/src/requests/messages.h
index 89765d6e34..a0d782612a 100644
--- a/protocols/FacebookRM/src/requests/messages.h
+++ b/protocols/FacebookRM/src/requests/messages.h
@@ -37,40 +37,37 @@ public:
// Use own persistent connection for sending messages
Persistent = MESSAGES;
- Url
- << "dpr=1";
+ Url << INT_PARAM("dpr", 1);
if (mir_strlen(captcha) > 0) {
Body
- << CHAR_VALUE("captcha_persist_data", captchaPersistData)
- << "recaptcha_challenge_field="
- << CHAR_VALUE("captcha_response", captcha);
+ << CHAR_PARAM("captcha_persist_data", captchaPersistData)
+ << CHAR_PARAM("captcha_response", captcha);
}
Body
- << "client=mercury" // or "web_messenger" (whole messages page)
- << "action_type=ma-type:user-generated-message";
+ << CHAR_PARAM("client", "mercury") // or "web_messenger" (whole messages page)
+ << CHAR_PARAM("action_type", "ma-type:user-generated-message");
// Experimental sticker sending support
std::string message_text = messageText; // FIXME: Rewrite this without std::string...
if (message_text.substr(0, 10) == "[[sticker:" && message_text.substr(message_text.length() - 2) == "]]") {
Body
<< "body="
- << CHAR_VALUE("sticker_id", ptrA(mir_urlEncode(message_text.substr(10, message_text.length() - 10 - 2).c_str())))
- << "has_attachment=true";
+ << CHAR_PARAM("sticker_id", ptrA(mir_urlEncode(message_text.substr(10, message_text.length() - 10 - 2).c_str())))
+ << BOOL_PARAM("has_attachment", true);
// TODO: For sending GIF images instead of "sticker_id=" there is "image_ids[0]=", otherwise it's same
}
else {
Body
- << CHAR_VALUE("body", ptrA(mir_urlEncode(messageText)))
- << "has_attachment=false";
+ << CHAR_PARAM("body", ptrA(mir_urlEncode(messageText)))
+ << BOOL_PARAM("has_attachment", false);
}
Body
- << "ephemeral_ttl_mode=0"
- // << "force_sms=true" // TODO: This is present always when sending via "web_messenger"
- << CHAR_VALUE("message_id", messageId)
- << CHAR_VALUE("offline_threading_id", messageId); // Same as message ID
+ << INT_PARAM("ephemeral_ttl_mode", 0)
+ << CHAR_PARAM("message_id", messageId)
+ << CHAR_PARAM("offline_threading_id", messageId); // Same as message ID
if (isChat) {
// NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId
@@ -78,30 +75,29 @@ public:
if (threadFbid.substr(0, 3) == "id.")
threadFbid = threadFbid.substr(3);
- Body << CHAR_VALUE("thread_fbid", threadFbid.c_str());
+ Body << CHAR_PARAM("thread_fbid", threadFbid.c_str());
}
else {
Body
- << CHAR_VALUE("other_user_fbid", userId)
- << CHAR_VALUE("specific_to_list[0]", CMStringA(::FORMAT, "fbid:%s", userId))
- << CHAR_VALUE("specific_to_list[1]", CMStringA(::FORMAT, "fbid:%s", fc->self_.user_id.c_str()));
+ << CHAR_PARAM("other_user_fbid", userId)
+ << CHAR_PARAM("specific_to_list[0]", CMStringA(::FORMAT, "fbid:%s", userId))
+ << CHAR_PARAM("specific_to_list[1]", CMStringA(::FORMAT, "fbid:%s", fc->self_.user_id.c_str()));
}
Body
- << "signature_id=" // TODO: How to generate signature ID? It is present only when sending via "mercury"
- << "source=source:chat:web" // or "source:titan:web" for web_messenger
- << CHAR_VALUE("timestamp", utils::time::mili_timestamp().c_str())
- << "ui_push_phase=V3"
-
- << CHAR_VALUE("__user", fc->self_.user_id.c_str())
- << CHAR_VALUE("__dyn", fc->__dyn())
- << CHAR_VALUE("__req", fc->__req())
- << CHAR_VALUE("__rev", fc->__rev())
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
- << "__a=1"
- << "__pc=PHASED:DEFAULT"
- << "__be=-1";
+ // << "signature_id=" // TODO: How to generate signature ID? It is present only when sending via "mercury"
+ << CHAR_PARAM("source", "source:chat:web") // or "source:titan:web" for web_messenger
+ << CHAR_PARAM("timestamp", utils::time::mili_timestamp().c_str())
+ << CHAR_PARAM("ui_push_phase", "V3")
+ << 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())
+ << INT_PARAM("__a", 1)
+ << CHAR_PARAM("__pc", "PHASED:DEFAULT")
+ << INT_PARAM("__be", -1);
}
};
@@ -113,25 +109,24 @@ public:
SendTypingRequest(facebook_client *fc, const char *userId, bool isChat, bool isTyping) :
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/messaging/typ.php")
{
- Url
- << "dpr=1";
+ Url << INT_PARAM("dpr", 1);
ptrA idEncoded(mir_urlEncode(userId));
Body
- << (isTyping ? "typ=1" : "typ=0")
- << CHAR_VALUE("to", isChat ? "" : idEncoded)
- << CHAR_VALUE("thread", idEncoded)
- << "source=mercury-chat"
- << CHAR_VALUE("__user", fc->self_.user_id.c_str())
- << CHAR_VALUE("__dyn", fc->__dyn())
- << CHAR_VALUE("__req", fc->__req())
- << CHAR_VALUE("__rev", fc->__rev())
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
- << "__a=1"
- << "__pc=PHASED:DEFAULT"
- << "__be=-1";
+ << INT_PARAM("typ", isTyping ? 1 : 0)
+ << CHAR_PARAM("to", isChat ? "" : idEncoded)
+ << CHAR_PARAM("thread", idEncoded)
+ << CHAR_PARAM("source", "mercury-chat")
+ << 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("__pc", "PHASED:DEFAULT")
+ << INT_PARAM("__a", 1)
+ << INT_PARAM("__be", -1);
}
};
@@ -142,8 +137,7 @@ public:
MarkMessageReadRequest(facebook_client *fc, const LIST<char> &ids) :
HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/change_read_status.php")
{
- Url
- << "__a=1";
+ Url << INT_PARAM("__a", 1);
for (int i = 0; i < ids.getCount(); i++) {
std::string id_ = ids[i];
@@ -151,18 +145,18 @@ public:
if (id_.substr(0, 3) == "id.")
id_ = id_.substr(3);
- CMStringA id(::FORMAT, "ids[%s]=true", ptrA(mir_urlEncode(id_.c_str())));
- Body << id.c_str();
+ CMStringA id(::FORMAT, "ids[%s]", ptrA(mir_urlEncode(id_.c_str())));
+ Body << BOOL_PARAM(id, true);
}
Body
- << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
- << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
- << CHAR_VALUE("__user", fc->self_.user_id.c_str())
- << CHAR_VALUE("__dyn", fc->__dyn())
- << CHAR_VALUE("__req", fc->__req())
- << CHAR_VALUE("__rev", fc->__rev())
- << "__a=1";
+ << CHAR_PARAM("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_PARAM("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_PARAM("__user", fc->self_.user_id.c_str())
+ << CHAR_PARAM("__dyn", fc->__dyn())
+ << CHAR_PARAM("__req", fc->__req())
+ << CHAR_PARAM("__rev", fc->__rev())
+ << INT_PARAM("__a", 1);
}
};