From 6c1f21f10c4f740c88c56228a725b5f47ce4ca52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Wed, 1 May 2024 10:10:36 +0200 Subject: relay: add option relay.api.remote_get_lines (issue #2066) --- .../relay/api/remote/relay-remote-network.c | 4 +++- src/plugins/relay/relay-config.c | 25 ++++++++++++++++++++++ src/plugins/relay/relay-config.h | 2 ++ 3 files changed, 30 insertions(+), 1 deletion(-) (limited to 'src/plugins/relay') diff --git a/src/plugins/relay/api/remote/relay-remote-network.c b/src/plugins/relay/api/remote/relay-remote-network.c index 49433ee2e..12b05cd90 100644 --- a/src/plugins/relay/api/remote/relay-remote-network.c +++ b/src/plugins/relay/api/remote/relay-remote-network.c @@ -34,6 +34,7 @@ #include "../../../weechat-plugin.h" #include "../../relay.h" #include "../../relay-auth.h" +#include "../../relay-config.h" #include "../../relay-http.h" #include "../../relay-raw.h" #include "../../relay-remote.h" @@ -384,7 +385,8 @@ relay_remote_network_recv_text (struct t_relay_remote *remote, request, strlen (request)); snprintf (request, sizeof (request), "{\"request\": \"GET /api/buffers?" - "lines=-100&nicks=true&colors=weechat\"}"); + "lines=-%d&nicks=true&colors=weechat\"}", + weechat_config_integer (relay_config_api_remote_get_lines)); relay_remote_network_send (remote, RELAY_MSG_STANDARD, request, strlen (request)); } diff --git a/src/plugins/relay/relay-config.c b/src/plugins/relay/relay-config.c index dfd00ef57..f41af69e5 100644 --- a/src/plugins/relay/relay-config.c +++ b/src/plugins/relay/relay-config.c @@ -49,6 +49,7 @@ struct t_config_section *relay_config_section_look = NULL; struct t_config_section *relay_config_section_color = NULL; struct t_config_section *relay_config_section_network = NULL; struct t_config_section *relay_config_section_irc = NULL; +struct t_config_section *relay_config_section_api = NULL; struct t_config_section *relay_config_section_port = NULL; struct t_config_section *relay_config_section_path = NULL; struct t_config_section *relay_config_section_remote = NULL; @@ -100,6 +101,10 @@ struct t_config_option *relay_config_irc_backlog_since_last_message = NULL; struct t_config_option *relay_config_irc_backlog_tags = NULL; struct t_config_option *relay_config_irc_backlog_time_format = NULL; +/* relay config, api section */ + +struct t_config_option *relay_config_api_remote_get_lines = NULL; + /* other */ int relay_config_auto_open_buffer[RELAY_NUM_PROTOCOLS]; @@ -1795,6 +1800,26 @@ relay_config_init () NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } + /* section api */ + relay_config_section_api = weechat_config_new_section ( + relay_config_file, "api", + 0, 0, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); + if (relay_config_section_api) + { + relay_config_api_remote_get_lines = weechat_config_new_option ( + relay_config_file, relay_config_section_api, + "remote_get_lines", "integer", + N_("number of lines to retrieve on each buffer when connecting " + "to a remote relay"), + NULL, 0, INT_MAX, "1000", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + } + /* section port */ relay_config_section_port = weechat_config_new_section ( relay_config_file, "port", diff --git a/src/plugins/relay/relay-config.h b/src/plugins/relay/relay-config.h index afc8afc96..f29956d8b 100644 --- a/src/plugins/relay/relay-config.h +++ b/src/plugins/relay/relay-config.h @@ -68,6 +68,8 @@ extern struct t_config_option *relay_config_irc_backlog_since_last_message; extern struct t_config_option *relay_config_irc_backlog_tags; extern struct t_config_option *relay_config_irc_backlog_time_format; +extern struct t_config_option *relay_config_api_remote_get_lines; + extern int relay_config_auto_open_buffer[]; extern int relay_config_display_clients[]; extern regex_t *relay_config_regex_allowed_ips; -- cgit v1.2.3