summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/FacebookRM/src/client.h2
-rw-r--r--protocols/FacebookRM/src/communication.cpp119
-rw-r--r--protocols/FacebookRM/src/contacts.cpp14
-rw-r--r--protocols/FacebookRM/src/messages.cpp8
-rw-r--r--protocols/FacebookRM/src/process.cpp17
5 files changed, 83 insertions, 77 deletions
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h
index 7df4d7a4d3..22297ebf26 100644
--- a/protocols/FacebookRM/src/client.h
+++ b/protocols/FacebookRM/src/client.h
@@ -158,7 +158,7 @@ public:
}
std::string __inline __rev() {
- return "2288795"; // FIXME: Some version of communication protocol? This version is from 17.4.2016
+ return "2509236"; // FIXME: Some version of communication protocol? This version is from 17.8.2016
}
////////////////////////////////////////////////////////////
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 6662735d26..f4fd7cf13d 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -283,6 +283,8 @@ std::string facebook_client::choose_server(RequestType request_type)
std::string facebook_client::choose_action(RequestType request_type, std::string *get_data)
{
+ // NOTE: Parameter "client" used in some requests's POST data could be "jewel" (top bar?), "mercury" (chat window, source=source:chat:web) or "web_messenger" (whole chat messages page, source=source:titan:web)
+
switch (request_type)
{
case REQUEST_LOGIN:
@@ -306,11 +308,11 @@ std::string facebook_client::choose_action(RequestType request_type, std::string
case REQUEST_DTSG:
return "/editprofile.php?edit=current_city&type=basic";
- case REQUEST_USER_INFO:
- return "/ajax/chat/user_info.php?__a=1";
+ case REQUEST_USER_INFO: // ok, 17.8.2016
+ return "/chat/user_info/?dpr=1";
- case REQUEST_USER_INFO_ALL:
- return "/ajax/chat/user_info_all.php?__a=1&viewer=" + self_.user_id;
+ case REQUEST_USER_INFO_ALL: // ok, 17.8.2016
+ return "/chat/user_info_all/?dpr=1&viewer=" + self_.user_id;
case REQUEST_USER_INFO_MOBILE:
{
@@ -335,9 +337,9 @@ std::string facebook_client::choose_action(RequestType request_type, std::string
return action;
}
- case REQUEST_UNREAD_THREADS:
+ case REQUEST_UNREAD_THREADS: // ok, 17.8.2016
{
- return "/ajax/mercury/unread_threads.php?__a=1";
+ return "/ajax/mercury/unread_threads.php?dpr=1";
}
case REQUEST_DELETE_FRIEND:
@@ -380,12 +382,12 @@ std::string facebook_client::choose_action(RequestType request_type, std::string
return "/bookmarks/pages?";
}
- case REQUEST_NOTIFICATIONS:
+ case REQUEST_NOTIFICATIONS: // ok, 17.8.2016
{
- return "/ajax/notifications/client/get.php?__a=1";
+ return "/ajax/notifications/client/get.php?dpr=1";
}
- case REQUEST_RECONNECT:
+ case REQUEST_RECONNECT: // ok, 17.8.2016
{
std::string action = "/ajax/presence/reconnect.php?__a=1&reason=%s&fb_dtsg=%s&__user=%s";
@@ -399,6 +401,7 @@ std::string facebook_client::choose_action(RequestType request_type, std::string
action += "&__dyn=" + __dyn();
action += "&__req=" + __req();
action += "&__rev=" + __rev();
+ action += "&__pc=PHASED:DEFAULT&__be=-1&__a=1";
return action;
}
@@ -428,12 +431,12 @@ std::string facebook_client::choose_action(RequestType request_type, std::string
}
case REQUEST_MESSAGES_SEND:
- return "/ajax/mercury/send_messages.php?__a=1";
+ return "/messaging/send/?dpr=1";
- case REQUEST_THREAD_INFO:
- return "/ajax/mercury/thread_info.php?__a=1";
+ case REQUEST_THREAD_INFO: // ok, 17.8.2016
+ return "/ajax/mercury/thread_info.php?dpr=1";
- case REQUEST_THREAD_SYNC:
+ case REQUEST_THREAD_SYNC: // TODO: This doesn't work anymore
return "/ajax/mercury/thread_sync.php?__a=1";
case REQUEST_MESSAGES_RECEIVE:
@@ -491,7 +494,7 @@ std::string facebook_client::choose_action(RequestType request_type, std::string
}
case REQUEST_VISIBILITY:
- return "/ajax/chat/privacy/visibility.php?__a=1";
+ return "/ajax/chat/privacy/visibility.php?dpr=1"; // ok, 17.8.2016
case REQUEST_POKE:
return "/pokes/dialog/?__a=1";
@@ -509,7 +512,7 @@ std::string facebook_client::choose_action(RequestType request_type, std::string
}
case REQUEST_TYPING_SEND:
- return "/ajax/messaging/typ.php?__a=1";
+ return "/ajax/messaging/typ.php?dpr=1"; // ok, 17.8.2016
case REQUEST_ON_THIS_DAY:
{
@@ -1214,7 +1217,8 @@ bool facebook_client::chat_state(bool online)
data += "&__req=" + __req();
data += "&ttstamp=" + ttstamp_;
data += "&__rev=" + __rev();
- http::response resp = flap(REQUEST_VISIBILITY, &data); // NOTE: Request revised 11.2.2016
+ data += "&__a=1&__pc=PHASED:DEFAULT&__be=-1";
+ http::response resp = flap(REQUEST_VISIBILITY, &data); // NOTE: Request revised 17.8.2016
if (!resp.error_title.empty())
return handle_error("chat_state");
@@ -1422,7 +1426,28 @@ int facebook_client::send_message(int seqid, MCONTACT hContact, const std::strin
return SEND_MESSAGE_ERROR;
}
- data += "&message_batch[0][action_type]=ma-type:user-generated-message";
+ data += "&client=mercury"; // or "web_messenger" (whole messages page)
+ data += "&action_type=ma-type:user-generated-message";
+
+ // Experimental sticker sending support
+ if (message_text.substr(0, 10) == "[[sticker:" && message_text.substr(message_text.length() - 2) == "]]") {
+ data += "&body=";
+ data += "&sticker_id=" + utils::url::encode(message_text.substr(10, message_text.length() - 10 - 2));
+ data += "&has_attachment=true";
+ // TODO: For sending GIF images instead of "sticker_id=" there is "image_ids[0]=", otherwise it's same
+ }
+ else {
+ data += "&body=" + utils::url::encode(message_text);
+ data += "&has_attachment=false";
+ }
+
+ data += "&ephemeral_ttl_mode=0";
+ // data += "&force_sms=true" // TODO: This is present always when sending via "web_messenger"
+
+ // Probably we can generate any random messageID, it just have to be numeric and don't start with "0". We will receive it in response as "client_message_id".
+ std::string messageId = utils::text::rand_string(10, "123456789", &this->random_);
+ data += "&message_id=" + messageId;
+ data += "&offline_threading_id=" + messageId; // Same as message ID
if (isChatRoom) {
// NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId
@@ -1430,60 +1455,30 @@ int facebook_client::send_message(int seqid, MCONTACT hContact, const std::strin
if (thread_fbid.substr(0, 3) == "id.")
thread_fbid = thread_fbid.substr(3);
- data += "&message_batch[0][thread_fbid]=" + thread_fbid;
+ data += "&thread_fbid=" + thread_fbid;
} else {
- data += "&message_batch[0][specific_to_list][0]=fbid:" + std::string(userId);
- data += "&message_batch[0][specific_to_list][1]=fbid:" + this->self_.user_id;
- data += "&message_batch[0][other_user_fbid]=" + std::string(userId);
- }
-
- data += "&message_batch[0][thread_id]=";
- data += "&message_batch[0][author]=fbid:" + this->self_.user_id;
- data += "&message_batch[0][author_email]";
- data += "&message_batch[0][timestamp]=" + utils::time::mili_timestamp();
- data += "&message_batch[0][timestamp_absolute]";
- data += "&message_batch[0][timestamp_relative]";
- data += "&message_batch[0][timestamp_time_passed]";
- data += "&message_batch[0][is_unread]=false";
- data += "&message_batch[0][is_forward]=false";
- data += "&message_batch[0][is_filtered_content]=false";
- data += "&message_batch[0][is_filtered_content_bh]=false";
- data += "&message_batch[0][is_filtered_content_account]=false";
- data += "&message_batch[0][is_filtered_content_quasar]=false";
- data += "&message_batch[0][is_filtered_content_invalid_app]=false";
- data += "&message_batch[0][is_spoof_warning]=false";
- data += "&message_batch[0][source]=source:chat:web";
- data += "&message_batch[0][source_tags][0]=source:chat";
-
- // Experimental sticker sending support
- if (message_text.substr(0, 10) == "[[sticker:" && message_text.substr(message_text.length() - 2) == "]]") {
- data += "&message_batch[0][body]=";
- data += "&message_batch[0][sticker_id]=" + utils::url::encode(message_text.substr(10, message_text.length()-10-2));
+ data += "&other_user_fbid=" + std::string(userId);
+ data += "&specific_to_list[0]=fbid:" + std::string(userId);
+ data += "&specific_to_list[1]=fbid:" + this->self_.user_id;
}
- else {
- data += "&message_batch[0][body]=" + utils::url::encode(message_text);
- }
-
- data += "&message_batch[0][has_attachment]=false";
- data += "&message_batch[0][html_body]=false";
- data += "&message_batch[0][signatureID]";
- data += "&message_batch[0][ui_push_phase]";
- data += "&message_batch[0][status]=0";
- data += "&message_batch[0][offline_threading_id]";
- data += "&message_batch[0][message_id]";
- data += "&message_batch[0][ephemeral_ttl_mode]=0";
- data += "&message_batch[0][manual_retry_cnt]=0";
- data += "&client=mercury&__a=1&__be=0&__pc=EXP1:DEFAULT";
- data += "&fb_dtsg=" + this->dtsg_;
+
+ data += "&signature_id="; // TODO: How to generate signature ID? It is present only when sending via "mercury"
+ data += "&source=source:chat:web"; // or "source:titan:web" for web_messenger
+ data += "&timestamp=" + utils::time::mili_timestamp();
+ data += "&ui_push_phase=V3";
data += "&__user=" + this->self_.user_id;
- data += "&ttstamp=" + ttstamp_;
+ data += "&__a=1";
data += "&__dyn=" + __dyn();
data += "&__req=" + __req();
+ data += "&__be=-1";
+ data += "&__pc=PHASED:DEFAULT";
+ data += "&fb_dtsg=" + this->dtsg_;
+ data += "&ttstamp=" + ttstamp_;
data += "&__rev=" + __rev();
{
ScopedLock s(send_message_lock_);
- resp = flap(REQUEST_MESSAGES_SEND, &data); // NOTE: Request revised 11.2.2016
+ resp = flap(REQUEST_MESSAGES_SEND, &data); // NOTE: Request revised 17.8.2016
*error_text = resp.error_text;
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index 8893287514..1d780d6e72 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -191,11 +191,12 @@ std::string FacebookProto::ThreadIDToContactID(const std::string &thread_id)
data += "&fb_dtsg=" + facy.dtsg_;
data += "&ttstamp=" + facy.ttstamp_;
data += "&__rev=" + facy.__rev();
+ data += "&__pc=PHASED:DEFAULT&__be=-1&__a=1";
data += "&threads[thread_ids][0]=" + utils::url::encode(thread_id);
std::string user_id;
- http::response resp = facy.flap(REQUEST_THREAD_INFO, &data); // NOTE: Request revised 1.9.2015
+ http::response resp = facy.flap(REQUEST_THREAD_INFO, &data); // NOTE: Request revised 17.8.2016
if (resp.code == HTTP_CODE_OK) {
CODE_BLOCK_TRY
@@ -233,8 +234,9 @@ void FacebookProto::LoadContactInfo(facebook_user* fbu)
data += "&fb_dtsg=" + facy.dtsg_;
data += "&ttstamp=" + facy.ttstamp_;
data += "&__rev=" + facy.__rev();
+ data += "&__pc=PHASED:DEFAULT&__be=-1&__a=1";
- http::response resp = facy.flap(REQUEST_USER_INFO, &data); // NOTE: Request revised 11.2.2016
+ http::response resp = facy.flap(REQUEST_USER_INFO, &data); // NOTE: Request revised 17.8.2016
if (resp.code == HTTP_CODE_OK) {
CODE_BLOCK_TRY
@@ -304,6 +306,7 @@ void FacebookProto::LoadParticipantsNames(facebook_chatroom *fbc)
data += "&fb_dtsg=" + facy.dtsg_;
data += "&ttstamp=" + facy.ttstamp_;
data += "&__rev=" + facy.__rev();
+ data += "&__pc=PHASED:DEFAULT&__be=-1&__a=1";
for (std::string::size_type i = 0; i < namelessIds.size(); i++) {
std::string pos = utils::conversion::to_string(&i, UTILS_CONV_UNSIGNED_NUMBER);
@@ -311,7 +314,7 @@ void FacebookProto::LoadParticipantsNames(facebook_chatroom *fbc)
data += "&ids[" + pos + "]=" + id;
}
- http::response resp = facy.flap(REQUEST_USER_INFO, &data); // NOTE: Request revised 11.2.2016
+ http::response resp = facy.flap(REQUEST_USER_INFO, &data); // NOTE: Request revised 17.8.2016
if (resp.code == HTTP_CODE_OK) {
CODE_BLOCK_TRY
@@ -359,18 +362,19 @@ void FacebookProto::LoadChatInfo(facebook_chatroom *fbc)
data += "&fb_dtsg=" + facy.dtsg_;
data += "&ttstamp=" + facy.ttstamp_;
data += "&__rev=" + facy.__rev();
+ data += "&__pc=PHASED:DEFAULT&__be=-1&__a=1";
std::string thread_id = utils::url::encode(fbc->thread_id);
// request info about thread
data += "&threads[thread_ids][0]=" + thread_id;
- // TODO: ABILITY TO DEFINE TIMESTAMP! (way to load history since specific moment? ... offset seems to does nothing at all)
+ // TODO: ABILITY TO DEFINE TIMESTAMP! (way to load history since specific moment? probably as replacement for removed sync_threads request?)
/* messages[user_ids][<<userid>>][offset]=11
messages[user_ids][<<userid>>][timestamp]=1446369866009 // most recent message has this timestamp (included)
messages[user_ids][<<userid>>][limit]=20 */
- http::response resp = facy.flap(REQUEST_THREAD_INFO, &data); // NOTE: Request revised 12.2.2016
+ http::response resp = facy.flap(REQUEST_THREAD_INFO, &data); // NOTE: Request revised 17.8.2016
if (resp.code != HTTP_CODE_OK) {
facy.handle_error("LoadChatInfo");
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp
index 5076730817..83fc2c410a 100644
--- a/protocols/FacebookRM/src/messages.cpp
+++ b/protocols/FacebookRM/src/messages.cpp
@@ -97,8 +97,9 @@ void FacebookProto::SendChatMsgWorker(void *p)
post_data += "&ttstamp=" + facy.ttstamp_;
post_data += "&__rev=" + facy.__rev();
post_data += "&threads[thread_ids][0]=" + utils::url::encode(data->chat_id);
+ post_data += "&__pc=PHASED:DEFAULT&__be=-1&__a=1";
- http::response resp = facy.flap(REQUEST_THREAD_INFO, &post_data); // NOTE: Request revised 1.9.2015
+ http::response resp = facy.flap(REQUEST_THREAD_INFO, &post_data); // NOTE: Request revised 17.8.2016
tid = utils::text::source_get_value(&resp.data, 2, "\"thread_id\":\"", "\"");
if (!tid.empty() && tid.compare("null"))
@@ -164,10 +165,11 @@ void FacebookProto::SendTypingWorker(void *p)
data += "&__req=" + facy.__req();
data += "&fb_dtsg=" + facy.dtsg_;
- data += "&ttsamp=" + facy.ttstamp_;
+ data += "&ttstamp=" + facy.ttstamp_;
data += "&__rev=" + facy.__rev();
+ data += "&__pc=PHASED:DEFAULT&__be=-1&__a=1";
- http::response resp = facy.flap(REQUEST_TYPING_SEND, &data); // NOTE: Request revised 11.2.2016
+ http::response resp = facy.flap(REQUEST_TYPING_SEND, &data); // NOTE: Request revised 17.8.2016
}
delete typing;
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index cbc7848bc4..bf42ab2f87 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -52,8 +52,9 @@ void FacebookProto::ProcessFriendList(void*)
data += "&fb_dtsg=" + facy.dtsg_;
data += "&ttstamp=" + facy.ttstamp_;
data += "&__rev=" + facy.__rev();
+ data += "&__pc=PHASED:DEFAULT&__be=-1&__a=1";
- http::response resp = facy.flap(REQUEST_USER_INFO_ALL, &data); // NOTE: Request revised 11.2.2016
+ http::response resp = facy.flap(REQUEST_USER_INFO_ALL, &data); // NOTE: Request revised 17.8.2016
if (resp.code != HTTP_CODE_OK) {
facy.handle_error("load_friends");
@@ -192,11 +193,13 @@ void FacebookProto::ProcessUnreadMessages(void*)
facy.handle_entry("ProcessUnreadMessages");
- std::string data = "folders[0]=inbox&folders[1]=other"; // TODO: I'm not sure if this is still valid/used on fb side (or it has any effect at all)
+ std::string data = "folders[0]=inbox&folders[1]=other"; // TODO: "other" is probably unused, and there is now "pending" instead
data += "&client=mercury";
data += "&__user=" + facy.self_.user_id;
data += "&fb_dtsg=" + facy.dtsg_;
data += "&__a=1&__dyn=&__req=&ttstamp=" + facy.ttstamp_;
+ data += "&__rev=" + facy.__rev();
+ data += "&__pc=PHASED:DEFAULT&__be=-1";
http::response resp = facy.flap(REQUEST_UNREAD_THREADS, &data);
@@ -255,6 +258,7 @@ void FacebookProto::ProcessUnreadMessage(void *pParam)
data += "&fb_dtsg=" + facy.dtsg_;
data += "&ttstamp=" + facy.ttstamp_;
data += "&__rev=" + facy.__rev();
+ data += "&__pc=PHASED:DEFAULT&__be=-1&__a=1";
for (std::vector<std::string>::size_type i = 0; i < threads->size(); i++) {
std::string thread_id = utils::url::encode(threads->at(i));
@@ -270,7 +274,7 @@ void FacebookProto::ProcessUnreadMessage(void *pParam)
data += "]=" + thread_id;
}
- resp = facy.flap(REQUEST_THREAD_INFO, &data); // NOTE: Request revised 1.9.2015
+ resp = facy.flap(REQUEST_THREAD_INFO, &data); // NOTE: Request revised 17.8.2016
if (resp.code == HTTP_CODE_OK) {
@@ -359,6 +363,7 @@ void FacebookProto::LoadLastMessages(void *pParam)
data += "&fb_dtsg=" + facy.dtsg_;
data += "&ttstamp=" + facy.ttstamp_;
data += "&__rev=" + facy.__rev();
+ data += "&__pc=PHASED:DEFAULT&__be=-1&__a=1";
bool isChat = isChatRoom(hContact);
@@ -385,7 +390,7 @@ void FacebookProto::LoadLastMessages(void *pParam)
// request info about thread
data += "&threads[" + type + "][0]=" + id;
- http::response resp = facy.flap(REQUEST_THREAD_INFO, &data); // NOTE: Request revised 1.9.2015
+ http::response resp = facy.flap(REQUEST_THREAD_INFO, &data); // NOTE: Request revised 17.8.2016
if (resp.code != HTTP_CODE_OK || resp.data.empty()) {
facy.handle_error("LoadLastMessages");
@@ -978,16 +983,16 @@ void FacebookProto::ProcessNotifications(void*)
data += "&__dyn=" + facy.__dyn();
data += "&__req=" + facy.__req();
data += "&__rev=" + facy.__rev();
+ data += "&__pc=PHASED:DEFAULT&__be=-1&__a=1";
// Get notifications
- http::response resp = facy.flap(REQUEST_NOTIFICATIONS, &data); // NOTE: Request revised 11.2.2016
+ http::response resp = facy.flap(REQUEST_NOTIFICATIONS, &data); // NOTE: Request revised 17.8.2016
if (resp.code != HTTP_CODE_OK) {
facy.handle_error("notifications");
return;
}
-
// Process notifications
debugLogA("*** Starting processing notifications");