1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-02 15:53:12 +02:00

relay/api: add body types buffers and lines (array)

This commit is contained in:
Sébastien Helleu
2024-06-30 13:01:29 +02:00
parent a9ed58fae3
commit cac5717b41
4 changed files with 47 additions and 27 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
### Changed
- **breaking:** relay/api: flatten JSON event object sent to clients, always set "body_type" and "body" (null if there is no body) in websocket frame, add field "request_id" in websocket frame (request and response)
- **breaking:** relay/api: flatten JSON event object sent to clients, always set "body_type" and "body" (null if there is no body) in websocket frame, add body types `buffers` and `lines` (array), add field "request_id" in websocket frame (request and response)
- **breaking:** core, plugins: force "short_name" in buffers to non-empty value (name by default), remove buffer property "short_name_is_set"
- **breaking:** alias: display an error with `/alias add` or `/alias addcompletion` when the alias already exists, add options `addreplace` and `addreplacecompletion` in command `/alias` ([#2095](https://github.com/weechat/weechat/issues/2095))
- **breaking:** irc: rename parameter `-re` to `-raw` in command `/list` ([#2124](https://github.com/weechat/weechat/issues/2124))
+13 -8
View File
@@ -1390,14 +1390,19 @@ Responses to client are made with a JSON object containing these fields:
Body types that can be returned:
* `handshake`
* `version`
* `buffer`
* `line`
* `nick_group`
* `nick`
* `hotlist`
* `ping`
* `handshake` (object)
* `version` (object)
* `buffers` (array)
* `buffer` (object)
* `lines` (array)
* `line` (object)
* `nick_group` (object)
* `nick` (object)
* `hotlist` (object)
* `ping` (object)
[TIP]
You can browse these schemas online: https://weechat.org/api/[WeeChat Relay API ^↗^^].
Request example: get version:
+13 -8
View File
@@ -1417,14 +1417,19 @@ les champs suivants :
Les types de corps qui peuvent être retournés :
* `handshake`
* `version`
* `buffer`
* `line`
* `nick_group`
* `nick`
* `hotlist`
* `ping`
* `handshake` (objet)
* `version` (objet)
* `buffers` (tableau)
* `buffer` (objet)
* `lines` (tableau)
* `line` (objet)
* `nick_group` (objet)
* `nick` (objet)
* `hotlist` (objet)
* `ping` (objet)
[TIP]
Vous pouvez parcourir les schémas en ligne: https://weechat.org/api/[API relay WeeChat ^↗^^].
Exemple de requête : obtenir la version :
+20 -10
View File
@@ -576,16 +576,21 @@ RELAY_API_PROTOCOL_CALLBACK(buffers)
return RELAY_API_PROTOCOL_RC_OK;
}
json = relay_api_msg_line_data_to_json (ptr_line_data, colors);
if (json)
{
relay_api_msg_send_json (client, RELAY_HTTP_200_OK, NULL,
"line", json);
}
}
else
{
lines = relay_http_get_param_long (client->http_req, "lines", LONG_MAX);
json = relay_api_msg_lines_to_json (ptr_buffer, lines, colors);
}
if (json)
{
relay_api_msg_send_json (client, RELAY_HTTP_200_OK, NULL,
"line", json);
if (json)
{
relay_api_msg_send_json (client, RELAY_HTTP_200_OK, NULL,
"lines", json);
}
}
}
else if (strcmp (client->http_req->path_items[3], "nicks") == 0)
@@ -619,6 +624,11 @@ RELAY_API_PROTOCOL_CALLBACK(buffers)
{
json = relay_api_msg_buffer_to_json (ptr_buffer, lines, lines_free,
nicks, colors);
if (json)
{
relay_api_msg_send_json (client, RELAY_HTTP_200_OK, NULL,
"buffer", json);
}
}
else
{
@@ -635,11 +645,11 @@ RELAY_API_PROTOCOL_CALLBACK(buffers)
nicks, colors));
ptr_buffer = weechat_hdata_move (relay_hdata_buffer, ptr_buffer, 1);
}
}
if (json)
{
relay_api_msg_send_json (client, RELAY_HTTP_200_OK, NULL,
"buffer", json);
if (json)
{
relay_api_msg_send_json (client, RELAY_HTTP_200_OK, NULL,
"buffers", json);
}
}
}