1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 23:36:37 +02:00

relay/api: add support of buffer id in GET /api/buffers (issue #2081)

This commit is contained in:
Sébastien Helleu
2024-03-10 14:21:44 +01:00
parent 7ad3c1979c
commit aa989767a1
2 changed files with 51 additions and 2 deletions
+20 -1
View File
@@ -41,6 +41,21 @@
int relay_api_protocol_command_delay = 1; /* delay to execute command */
/*
* Searches buffer by id or full name.
*/
struct t_gui_buffer *
relay_api_search_buffer_id_name (const char *string)
{
struct t_gui_buffer *ptr_buffer;
ptr_buffer = weechat_buffer_search ("==id", string);
if (ptr_buffer)
return ptr_buffer;
return weechat_buffer_search ("==", string);
}
/*
* Callback for signals "buffer_*".
*/
@@ -358,6 +373,10 @@ RELAY_API_PROTOCOL_CALLBACK(version)
*
* Routes:
* GET /api/buffers
* GET /api/buffers/{buffer_id}
* GET /api/buffers/{buffer_id}/lines
* GET /api/buffers/{buffer_id}/lines/{line_id}
* GET /api/buffers/{buffer_id}/nicks
* GET /api/buffers/{buffer_name}
* GET /api/buffers/{buffer_name}/lines
* GET /api/buffers/{buffer_name}/lines/{line_id}
@@ -375,7 +394,7 @@ RELAY_API_PROTOCOL_CALLBACK(buffers)
ptr_buffer = NULL;
if (client->http_req->num_path_items > 2)
{
ptr_buffer = weechat_buffer_search ("==", client->http_req->path_items[2]);
ptr_buffer = relay_api_search_buffer_id_name (client->http_req->path_items[2]);
if (!ptr_buffer)
{
relay_api_msg_send_error_json (client, RELAY_HTTP_404_NOT_FOUND, NULL,