diff options
author | Robert Pösel <robyer@seznam.cz> | 2015-04-29 19:34:50 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2015-04-29 19:34:50 +0000 |
commit | c305dc7c4cb20072a003c349b8eec9f0e835b3c9 (patch) | |
tree | 9ec2ddb108bea7b07c9ae8b1cde6dfc8d4de580a /protocols/FacebookRM | |
parent | 36613a6ce15d9614e0883db8303dd2504c70ed4f (diff) |
Facebook: Some fixes for sending messages and fix crashes introduced in commit r13214; version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@13252 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r-- | protocols/FacebookRM/src/chat.cpp | 11 | ||||
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 23 | ||||
-rw-r--r-- | protocols/FacebookRM/src/messages.cpp | 7 | ||||
-rw-r--r-- | protocols/FacebookRM/src/version.h | 2 |
4 files changed, 29 insertions, 14 deletions
diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp index cae422e414..6db84be8b9 100644 --- a/protocols/FacebookRM/src/chat.cpp +++ b/protocols/FacebookRM/src/chat.cpp @@ -275,12 +275,13 @@ INT_PTR FacebookProto::OnJoinChat(WPARAM hContact, LPARAM) ptrT idT(getTStringA(hContact, "ChatRoomID")); ptrT nameT(getTStringA(hContact, "Nick")); + ptrT threadIdT(getTStringA(hContact, FACEBOOK_KEY_TID)); - if (!idT || !nameT) + if (!idT || !nameT || !threadIdT) return 0; facebook_chatroom *fbc; - std::tstring tthread_id = ptrT(getTStringA(hContact, FACEBOOK_KEY_TID)); + std::tstring tthread_id = threadIdT; std::map<std::tstring, facebook_chatroom*>::iterator it = facy.chat_rooms.find(tthread_id); if (it != facy.chat_rooms.end()) { @@ -330,9 +331,11 @@ INT_PTR FacebookProto::OnLeaveChat(WPARAM wParam, LPARAM) facy.clear_chatrooms(); } else if (!IsSpecialChatRoom(wParam)) { - std::tstring tthread_id = ptrT(getTStringA(wParam, FACEBOOK_KEY_TID)); + ptrT threadIdT(getTStringA(wParam, FACEBOOK_KEY_TID)); + if (!threadIdT) + return 0; - std::map<std::tstring, facebook_chatroom*>::iterator it = facy.chat_rooms.find(tthread_id); + std::map<std::tstring, facebook_chatroom*>::iterator it = facy.chat_rooms.find(std::tstring(threadIdT)); if (it != facy.chat_rooms.end()) { delete it->second; facy.chat_rooms.erase(it); diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 4f64bc6c28..7329b1ea6a 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -1228,21 +1228,32 @@ int facebook_client::send_message(int seqid, MCONTACT hContact, const std::strin data += "&captcha_response=" + captcha; } - std::string userId = ptrA(parent->getStringA(hContact, FACEBOOK_KEY_ID)); - std::string threadId = ptrA(parent->getStringA(hContact, FACEBOOK_KEY_TID)); boolean isChatRoom = parent->isChatRoom(hContact); + ptrA userId( parent->getStringA(hContact, FACEBOOK_KEY_ID)); + ptrA threadId( parent->getStringA(hContact, FACEBOOK_KEY_TID)); + + // Check if we have userId/threadId to be able to send message + if ((isChatRoom && (threadId == NULL || !mir_strcmp(threadId, "null"))) + || (!isChatRoom && (userId == NULL || !mir_strcmp(userId, "null")))) { + // This shouldn't happen unless user manually deletes some data via Database Editor++ + *error_text = Translate("Contact doesn't have required data in database."); + + handle_error("send_message"); + return SEND_MESSAGE_ERROR; + } + data += "&message_batch[0][action_type]=ma-type:user-generated-message"; if (isChatRoom) { - data += "&message_batch[0][thread_fbid]=" + threadId; + data += "&message_batch[0][thread_id]=" + std::string(threadId); } else { - data += "&message_batch[0][specific_to_list][0]=fbid:" + userId; + 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][client_thread_id]=user:" + userId; + data += "&message_batch[0][client_thread_id]=user:" + std::string(userId); } - data += "&message_batch[0][thread_id]"; + data += "&message_batch[0][thread_fbid]"; data += "&message_batch[0][author]=fbid:" + this->self_.user_id; data += "&message_batch[0][author_email]"; data += "&message_batch[0][coordinates]"; diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp index 0fc60765cd..401c8d1c92 100644 --- a/protocols/FacebookRM/src/messages.cpp +++ b/protocols/FacebookRM/src/messages.cpp @@ -84,11 +84,11 @@ void FacebookProto::SendChatMsgWorker(void *p) if (hContact) { ptrA tid_(getStringA(hContact, FACEBOOK_KEY_TID)); std::string tid; - if (tid_ != NULL) { + if (tid_ != NULL && mir_strcmp(tid_, "null")) { tid = tid_; } else { - std::string post_data = "threads[group_ids][0]=" + utils::url::encode(data->chat_id); + std::string post_data = "threads[thread_ids][0]=" + utils::url::encode(data->chat_id); post_data += "&fb_dtsg=" + facy.dtsg_; post_data += "&__user=" + facy.self_.user_id; post_data += "&phstamp=" + facy.phstamp(post_data); @@ -96,7 +96,8 @@ void FacebookProto::SendChatMsgWorker(void *p) http::response resp = facy.flap(REQUEST_THREAD_INFO, &post_data); tid = utils::text::source_get_value(&resp.data, 2, "\"thread_id\":\"", "\""); - setString(hContact, FACEBOOK_KEY_TID, tid.c_str()); + if (!tid.empty() && tid.compare("null")) + setString(hContact, FACEBOOK_KEY_TID, tid.c_str()); debugLogA(" Got thread info: %s = %s", data->chat_id.c_str(), tid.c_str()); } diff --git a/protocols/FacebookRM/src/version.h b/protocols/FacebookRM/src/version.h index 8bd14d00de..6837029385 100644 --- a/protocols/FacebookRM/src/version.h +++ b/protocols/FacebookRM/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 2
#define __RELEASE_NUM 10
-#define __BUILD_NUM 7
+#define __BUILD_NUM 8
#include <stdver.h>
|