summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/contacts.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2013-12-13 09:27:00 +0000
committerRobert Pösel <robyer@seznam.cz>2013-12-13 09:27:00 +0000
commita915fe3a7ff1f0512d91c1d4e2fe603b08458e6f (patch)
tree09203d632ef425fc11e567cc6e5d0b5b08d35f02 /protocols/FacebookRM/src/contacts.cpp
parent112bcc323d1532c8dac92f5af9b37f767879417f (diff)
Facebook: Fixed loading sent messages (from other connected devices)
git-svn-id: http://svn.miranda-ng.org/main/trunk@7170 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/contacts.cpp')
-rw-r--r--protocols/FacebookRM/src/contacts.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index c7487cd71d..f225c5b8c7 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -94,6 +94,50 @@ HANDLE FacebookProto::ContactIDToHContact(std::string user_id)
return 0;
}
+std::string FacebookProto::ThreadIDToContactID(std::string thread_id)
+{
+ std::string user_id;
+
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ if (!IsMyContact(hContact))
+ continue;
+
+ ptrA tid(getStringA(hContact, FACEBOOK_KEY_TID));
+ if (tid && !strcmp(tid, thread_id.c_str())) {
+ user_id = ptrA( getStringA(hContact, FACEBOOK_KEY_ID));
+ return user_id;
+ }
+ }
+
+ // We don't have any contact with thish thread_id cached, we must ask server
+
+ std::string data = "client=mercury";
+ data += "&__user=" + facy.self_.user_id;
+ data += "&fb_dtsg=" + (facy.dtsg_.length() ? facy.dtsg_ : "0");
+ data += "&__a=1&__dyn=&__req=&ttstamp=0";
+ data += "&threads[thread_ids][0]=" + utils::url::encode(thread_id);
+
+ http::response resp = facy.flap(REQUEST_THREAD_INFO, &data);
+
+ if (resp.code == HTTP_CODE_OK) {
+ CODE_BLOCK_TRY
+
+ facebook_json_parser* p = new facebook_json_parser(this);
+ p->parse_thread_info(&resp.data, &user_id);
+ delete p;
+
+ debugLogA("***** Thread info processed");
+
+ CODE_BLOCK_CATCH
+
+ debugLogA("***** Error processing thread info: %s", e.what());
+
+ CODE_BLOCK_END
+ }
+
+ return user_id;
+}
+
HANDLE FacebookProto::AddToContactList(facebook_user* fbu, ContactType type, bool dont_check)
{
HANDLE hContact;