summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/messages.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2012-06-11 13:32:53 +0000
committerRobert Pösel <robyer@seznam.cz>2012-06-11 13:32:53 +0000
commit50017f9b1e19f8a89aad7c4b68e1f58f81045dad (patch)
tree3d28ad857ce2b596788776a6ae11f59b680f7d35 /protocols/FacebookRM/messages.cpp
parent26791cc7ee10c73b00df9cc3cc38ff7ba06d8102 (diff)
FacebookRM sync.
git-svn-id: http://svn.miranda-ng.org/main/trunk@387 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/messages.cpp')
-rw-r--r--protocols/FacebookRM/messages.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/protocols/FacebookRM/messages.cpp b/protocols/FacebookRM/messages.cpp
index 9725ec40c9..def7a6b64b 100644
--- a/protocols/FacebookRM/messages.cpp
+++ b/protocols/FacebookRM/messages.cpp
@@ -83,7 +83,30 @@ void FacebookProto::SendChatMsgWorker(void *p)
send_chat *data = static_cast<send_chat*>(p);
std::string err_message = "";
- facy.send_message(data->chat_id, data->msg, &err_message, false );
+ HANDLE hContact = ChatIDToHContact(data->chat_id);
+ if (hContact) {
+ std::string tid;
+ DBVARIANT dbv;
+ if (!DBGetContactSettingString(hContact, m_szModuleName, FACEBOOK_KEY_TID, &dbv)) {
+ tid = dbv.pszVal;
+ DBFreeVariant(&dbv);
+ } else {
+ std::string post_data = "threads[group_ids][0]=" + data->chat_id;
+ post_data += "&fb_dtsg=" + (facy.dtsg_.length() ? facy.dtsg_ : "0");
+ post_data += "&__user=" + facy.self_.user_id;
+ post_data += "&phstamp=0";
+
+ http::response resp = facy.flap( FACEBOOK_REQUEST_THREAD_INFO, &post_data );
+ facy.validate_response(&resp);
+
+ tid = utils::text::source_get_value(&resp.data, 2, "\"thread_id\":\"", "\"");
+ DBWriteContactSettingString(hContact, m_szModuleName, FACEBOOK_KEY_TID, tid.c_str());
+ Log(" Got thread info: %s = %s", data->chat_id.c_str(), tid.c_str());
+ }
+
+ if (!tid.empty())
+ facy.send_message(tid, data->msg, &err_message, false, true );
+ }
delete data;
}