summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/requests
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2016-12-04 17:49:27 +0100
committerRobert Pösel <robyer@seznam.cz>2016-12-04 17:53:38 +0100
commitc3476b0dd031a7b85baa138c84e7d5751d67dbf5 (patch)
treeb66334136a49beb28acf6dbc685d365554620461 /protocols/FacebookRM/src/requests
parentb6c0516b0535f9f4dc14cd4c6ea506762d56cf3e (diff)
Facebook: Fix support for "new" group chats (dirty changes)
This commit is just quick workaround for group chat changes, where Facebook stopped using "id.XXX" ids, and instead use just "XXX" fbids. And for old existing chats tolerates old type, but for new forces this new format. I don't know how that, or changes in this commit, affects classic conversations, but in any case this commit should be cleaned and integrated better. Perhaps rewrite whole uses of "ids" to "fbids" everywhere.
Diffstat (limited to 'protocols/FacebookRM/src/requests')
-rw-r--r--protocols/FacebookRM/src/requests/history.h40
-rw-r--r--protocols/FacebookRM/src/requests/messages.h7
2 files changed, 37 insertions, 10 deletions
diff --git a/protocols/FacebookRM/src/requests/history.h b/protocols/FacebookRM/src/requests/history.h
index 426266c569..32496340a0 100644
--- a/protocols/FacebookRM/src/requests/history.h
+++ b/protocols/FacebookRM/src/requests/history.h
@@ -37,8 +37,14 @@ public:
setCommonBody(fc);
- const char *type = isChat ? "thread_ids" : "user_ids";
- ptrA idEncoded(mir_urlEncode(id));
+ 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
+ if (id_.substr(0, 3) == "id.")
+ id_ = id_.substr(3);
+ }
+ ptrA idEncoded(mir_urlEncode(id_.c_str()));
//if (loadMessages) {
// Grrr, offset doesn't work at all, we need to use timestamps to get back in history...
@@ -65,8 +71,14 @@ public:
setCommonBody(fc);
- const char *type = isChat ? "thread_ids" : "user_ids";
- ptrA idEncoded(mir_urlEncode(id));
+ 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
+ if (id_.substr(0, 3) == "id.")
+ id_ = id_.substr(3);
+ }
+ ptrA idEncoded(mir_urlEncode(id_.c_str()));
// Load only thread info
Body << CMStringA(::FORMAT, "threads[%s][0]=%s", type, idEncoded).c_str();
@@ -81,8 +93,14 @@ public:
setCommonBody(fc);
- const char *type = isChat ? "thread_ids" : "user_ids";
- ptrA idEncoded(mir_urlEncode(id));
+ 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
+ if (id_.substr(0, 3) == "id.")
+ id_ = id_.substr(3);
+ }
+ ptrA idEncoded(mir_urlEncode(id_.c_str()));
// Load messages
CMStringA begin(::FORMAT, "messages[%s][%s]", type, idEncoded);
@@ -106,17 +124,21 @@ public:
setCommonBody(fc);
for (int i = 0; i < ids.getCount(); i++) {
- ptrA idEncoded(mir_urlEncode(ids[i]));
+ // NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId
+ std::string id_ = ids[i]; // FIXME: Rewrite this without std::string...
+ if (id_.substr(0, 3) == "id.")
+ id_ = id_.substr(3);
+ ptrA idEncoded(mir_urlEncode(id_.c_str()));
// Load messages
- CMStringA begin(::FORMAT, "messages[%s][%s]", "thread_ids", idEncoded);
+ CMStringA begin(::FORMAT, "messages[%s][%s]", "thread_fbids", idEncoded);
Body
<< CMStringA(::FORMAT, "%s[offset]=%i", begin, offset).c_str()
//<< CMStringA(::FORMAT, "%s[timestamp]=%s", begin, "").c_str()
<< CMStringA(::FORMAT, "%s[limit]=%i", begin, limit).c_str();
// Load thread info
- Body << CMStringA(::FORMAT, "threads[%s][%i]=%s", "thread_ids", i, idEncoded).c_str();
+ Body << CMStringA(::FORMAT, "threads[%s][%i]=%s", "thread_fbids", i, idEncoded).c_str();
}
}
diff --git a/protocols/FacebookRM/src/requests/messages.h b/protocols/FacebookRM/src/requests/messages.h
index bc6c41784d..d2e468a6f9 100644
--- a/protocols/FacebookRM/src/requests/messages.h
+++ b/protocols/FacebookRM/src/requests/messages.h
@@ -146,7 +146,12 @@ public:
<< "__a=1";
for (int i = 0; i < ids.getCount(); i++) {
- CMStringA id(::FORMAT, "ids[%s]=true", ptrA(mir_urlEncode(ids[i])));
+ std::string id_ = ids[i];
+ // NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId
+ 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();
}