diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Matrix.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index a38c063..71e451d 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -993,4 +993,49 @@ namespace QuickMedia { this->homeserver = "https://" + homeserver; return PluginResult::OK; } + + PluginResult Matrix::on_start_typing(const std::string &room_id) { + Json::Value request_data(Json::objectValue); + request_data["typing"] = true; + request_data["timeout"] = 30000; // 30 sec timeout + + Json::StreamWriterBuilder builder; + builder["commentStyle"] = "None"; + builder["indentation"] = ""; + + std::vector<CommandArg> additional_args = { + { "-X", "PUT" }, + { "-H", "content-type: application/json" }, + { "--data-binary", Json::writeString(builder, std::move(request_data)) }, + { "-H", "Authorization: Bearer " + access_token } + }; + + std::string server_response; + if(download_to_string(homeserver + "/_matrix/client/r0/rooms/" + room_id + "/typing/" + url_param_encode(user_id) , server_response, std::move(additional_args), use_tor, true) != DownloadResult::OK) + return PluginResult::NET_ERR; + + return PluginResult::OK; + } + + PluginResult Matrix::on_stop_typing(const std::string &room_id) { + Json::Value request_data(Json::objectValue); + request_data["typing"] = false; + + Json::StreamWriterBuilder builder; + builder["commentStyle"] = "None"; + builder["indentation"] = ""; + + std::vector<CommandArg> additional_args = { + { "-X", "PUT" }, + { "-H", "content-type: application/json" }, + { "--data-binary", Json::writeString(builder, std::move(request_data)) }, + { "-H", "Authorization: Bearer " + access_token } + }; + + std::string server_response; + if(download_to_string(homeserver + "/_matrix/client/r0/rooms/" + room_id + "/typing/" + url_param_encode(user_id), server_response, std::move(additional_args), use_tor, true) != DownloadResult::OK) + return PluginResult::NET_ERR; + + return PluginResult::OK; + } }
\ No newline at end of file |