From c305dc7c4cb20072a003c349b8eec9f0e835b3c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Wed, 29 Apr 2015 19:34:50 +0000 Subject: 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 --- protocols/FacebookRM/src/communication.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'protocols/FacebookRM/src/communication.cpp') 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]"; -- cgit v1.2.3