From 0ac377d30674df75614b73d59a61175c27ae2317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 10 Mar 2024 10:17:51 +0100 Subject: relay/api: add a global variable to customize the command delay in POST /api/input The user can not change this, the variable will be set to 0 in unit tests to execute the command immediately. --- src/plugins/relay/api/relay-api-protocol.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/relay/api/relay-api-protocol.c b/src/plugins/relay/api/relay-api-protocol.c index 0cf6b8055..61b0b4a43 100644 --- a/src/plugins/relay/api/relay-api-protocol.c +++ b/src/plugins/relay/api/relay-api-protocol.c @@ -38,6 +38,8 @@ #include "relay-api-msg.h" #include "relay-api-protocol.h" +int relay_api_protocol_command_delay = 1; /* delay to execute command */ + /* * Callback for signals "buffer_*". @@ -463,6 +465,7 @@ RELAY_API_PROTOCOL_CALLBACK(input) const char *ptr_buffer_name, *ptr_command, *ptr_commands; struct t_gui_buffer *ptr_buffer; struct t_hashtable *options; + char str_delay[32]; json_body = cJSON_Parse(client->http_req->body); if (!json_body) @@ -534,7 +537,9 @@ RELAY_API_PROTOCOL_CALLBACK(input) * main loop (some commands like /upgrade executed now can cause * a crash) */ - weechat_hashtable_set (options, "delay", "1"); + snprintf (str_delay, sizeof (str_delay), + "%d", relay_api_protocol_command_delay); + weechat_hashtable_set (options, "delay", str_delay); /* execute the command, with the delay */ weechat_command_options (ptr_buffer, ptr_command, options); -- cgit v1.2.3