From 9fb104f688213bf1f3a324d5d240c8ab3bbc4997 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 27 Sep 2020 12:40:10 +0200 Subject: Matrix: add logout command --- src/plugins/Matrix.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 2321ff4..8b819a2 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -943,6 +943,22 @@ namespace QuickMedia { return PluginResult::OK; } + PluginResult Matrix::logout() { + Path session_path = get_storage_dir().join(name).join("session.json"); + remove(session_path.data.c_str()); + + std::vector additional_args = { + { "-X", "POST" }, + { "-H", "Authorization: Bearer " + access_token } + }; + + std::string server_response; + if(download_to_string(homeserver + "/_matrix/client/r0/logout", server_response, std::move(additional_args), use_tor, true) != DownloadResult::OK) + return PluginResult::NET_ERR; + + return PluginResult::OK; + } + PluginResult Matrix::load_and_verify_cached_session() { Path session_path = get_storage_dir().join(name).join("session.json"); std::string session_json_content; -- cgit v1.2.3