diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-09-27 12:40:10 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-09-27 12:40:10 +0200 |
commit | 9fb104f688213bf1f3a324d5d240c8ab3bbc4997 (patch) | |
tree | 5160859f150f5c005b223a832d66f35db3404197 /src/plugins | |
parent | c9a9450cf2737ade139944dc901cc80832ab4499 (diff) |
Matrix: add logout command
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Matrix.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
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<CommandArg> 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; |