diff options
author | George Hazan <ghazan@miranda.im> | 2018-01-15 19:19:37 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-01-15 19:19:37 +0300 |
commit | 85cfcb81a2ee0afad3cb3b2b7951f68ad74ce8bf (patch) | |
tree | b59672fd05d525df6702a509c4480c1aff66164b | |
parent | 5b0699740c8998327a2681f79347e1d630bbaab6 (diff) |
Facebook: action added to destroy chat history
-rw-r--r-- | protocols/FacebookRM/src/chat.cpp | 12 | ||||
-rw-r--r-- | protocols/FacebookRM/src/client.h | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/messages.cpp | 20 |
3 files changed, 33 insertions, 1 deletions
diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp index 7ccaef2459..266818d1af 100644 --- a/protocols/FacebookRM/src/chat.cpp +++ b/protocols/FacebookRM/src/chat.cpp @@ -26,7 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. enum ChatMenuItems { - IDM_INVITE = 10, IDM_EXIT, + IDM_INVITE = 10, IDM_EXIT, IDM_DESTROY, IDM_DETAILS = 20, IDM_HISTORY }; @@ -35,6 +35,7 @@ static const struct gc_item LogMenuItems[] = { { LPGENW("&Invite user..."), IDM_INVITE, MENU_ITEM, FALSE }, { LPGENW("E&xit chat session"), IDM_EXIT, MENU_ITEM, FALSE }, + { LPGENW("&Destroy chat session"), IDM_DESTROY, MENU_ITEM, FALSE }, }; static const struct gc_item NickMenuItems[] = @@ -125,6 +126,15 @@ int FacebookProto::OnGCEvent(WPARAM, LPARAM lParam) facy.sendRequest(facy.exitThreadRequest(it->second)); } break; + + case IDM_DESTROY: + { + std::string thread_id = _T2A(hook->ptszID, CP_UTF8); + auto it = facy.chat_rooms.find(thread_id); + if (it != facy.chat_rooms.end()) + if (IDOK == MessageBoxW(nullptr, TranslateT("Delete conversation"), TranslateT("This will permanently delete the conversation history"), MB_OKCANCEL)) + facy.sendRequest(facy.destroyThreadRequest(it->second)); + } } break; diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h index 67c1298854..d6c1fcb137 100644 --- a/protocols/FacebookRM/src/client.h +++ b/protocols/FacebookRM/src/client.h @@ -239,6 +239,8 @@ public: HttpRequest* sendMessageRequest(const char *userId, const char *threadId, const char *messageId, const char *messageText, bool isChat, const char *captcha, const char *captchaPersistData);
HttpRequest* sendTypingRequest(const char *userId, bool isChat, bool isTyping);
HttpRequest* markMessageReadRequest(const LIST<char> &ids);
+
+ HttpRequest* destroyThreadRequest(facebook_chatroom *fbc);
HttpRequest* exitThreadRequest(facebook_chatroom *fbc);
// notifications.cpp
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp index 9970d9be2c..5c128d5bb2 100644 --- a/protocols/FacebookRM/src/messages.cpp +++ b/protocols/FacebookRM/src/messages.cpp @@ -344,6 +344,26 @@ HttpRequest* facebook_client::markMessageReadRequest(const LIST<char> &ids) ///////////////////////////////////////////////////////////////////////////////////////// +HttpRequest* facebook_client::destroyThreadRequest(facebook_chatroom *fbc) +{ + HttpRequest *p = new HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/delete_thread.php"); + + p->Url << INT_PARAM("dpr", 1); + + p->Body + << CHAR_PARAM("ids[0]", fbc->thread_id.substr(3).c_str()) + << CHAR_PARAM("__user", self_.user_id.c_str()) + << CHAR_PARAM("fb_dtsg", dtsg_.c_str()) + << CHAR_PARAM("__dyn", __dyn()) + << CHAR_PARAM("__req", __req()) + << CHAR_PARAM("__rev", __rev()) + << CHAR_PARAM("__pc", "PHASED:DEFAULT") + << INT_PARAM("__a", 1) + << INT_PARAM("__be", 1); + + return p; +} + HttpRequest* facebook_client::exitThreadRequest(facebook_chatroom *fbc) { HttpRequest *p = new HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/messaging/send/"); |