aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-09-26 22:21:55 +0200
committerdec05eba <dec05eba@protonmail.com>2020-09-26 22:21:55 +0200
commit98d9b6856061e6c1951b03ca6b197d581e357189 (patch)
tree5ae068e902f48dd6a4a3d0a82e8e61186b298cdb /src/plugins
parent4eb9d876afd031582908db1ed0ffc10a47f76d57 (diff)
matrix: send start/stop typing
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Matrix.cpp45
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