1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

relay/api: add field "last_read_line_id" in GET /api/buffers

This commit is contained in:
Sébastien Helleu
2026-06-06 07:04:46 +02:00
parent 56f9ad68fb
commit befbcceb7f
8 changed files with 65 additions and 18 deletions
+1
View File
@@ -12,6 +12,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
- core: add condition on connected relay api clients in default value of option weechat.look.hotlist_add_conditions
- core: add `/mute` in default command for key `Alt`+`=` (toggle filters)
- relay/api: add field "last_read_line_id" in GET /api/buffers
### Added
+11 -5
View File
@@ -541,7 +541,8 @@ HTTP/1.1 200 OK
"plugin": "core",
"name": "weechat"
},
"keys": []
"keys": [],
"last_read_line_id": -1
},
{
"id": 1709932823423765,
@@ -571,7 +572,8 @@ HTTP/1.1 200 OK
"tls_version": "TLS1.3",
"host": "~alice@example.com"
},
"keys": []
"keys": [],
"last_read_line_id": -1
},
{
"id": 1709932823649069,
@@ -599,7 +601,8 @@ HTTP/1.1 200 OK
"nick": "alice",
"host": "~alice@example.com"
},
"keys": []
"keys": [],
"last_read_line_id": -1
}
]
----
@@ -655,7 +658,8 @@ HTTP/1.1 200 OK
"message": "Plugins loaded: alias, buflist, charset, exec, fifo, fset, guile, irc, javascript, logger, lua, perl, php, python, relay, ruby, script, spell, tcl, trigger, typing, xfer",
"tags": []
}
]
],
"last_read_line_id": -1
}
----
@@ -702,6 +706,7 @@ HTTP/1.1 200 OK
"host": "~alice@example.com"
},
"keys": [],
"last_read_line_id": -1,
"nicklist_root": {
"id": 0,
"parent_group_id": -1,
@@ -900,7 +905,8 @@ HTTP/1.1 200 OK
"key": "up",
"command": "/fset -up"
}
]
],
"last_read_line_id": -1
}
----
+11 -5
View File
@@ -551,7 +551,8 @@ HTTP/1.1 200 OK
"plugin": "core",
"name": "weechat"
},
"keys": []
"keys": [],
"last_read_line_id": -1
},
{
"id": 1709932823423765,
@@ -580,7 +581,8 @@ HTTP/1.1 200 OK
"tls_version": "TLS1.3",
"host": "~alice@example.com"
},
"keys": []
"keys": [],
"last_read_line_id": -1
},
{
"id": 1709932823649069,
@@ -607,7 +609,8 @@ HTTP/1.1 200 OK
"nick": "alice",
"host": "~alice@example.com"
},
"keys": []
"keys": [],
"last_read_line_id": -1
}
]
----
@@ -663,7 +666,8 @@ HTTP/1.1 200 OK
"message": "Plugins loaded: alias, buflist, charset, exec, fifo, fset, guile, irc, javascript, logger, lua, perl, php, python, relay, ruby, script, spell, tcl, trigger, typing, xfer",
"tags": []
}
]
],
"last_read_line_id": -1
}
----
@@ -709,6 +713,7 @@ HTTP/1.1 200 OK
"host": "~alice@example.com"
},
"keys": [],
"last_read_line_id": -1,
"nicklist_root": {
"id": 0,
"parent_group_id": -1,
@@ -906,7 +911,8 @@ HTTP/1.1 200 OK
"key": "up",
"command": "/fset -up"
}
]
],
"last_read_line_id": -1
}
----
+11 -5
View File
@@ -543,7 +543,8 @@ HTTP/1.1 200 OK
"plugin": "core",
"name": "weechat"
},
"keys": []
"keys": [],
"last_read_line_id": -1
},
{
"id": 1709932823423765,
@@ -573,7 +574,8 @@ HTTP/1.1 200 OK
"tls_version": "TLS1.3",
"host": "~alice@example.com"
},
"keys": []
"keys": [],
"last_read_line_id": -1
},
{
"id": 1709932823649069,
@@ -601,7 +603,8 @@ HTTP/1.1 200 OK
"nick": "alice",
"host": "~alice@example.com"
},
"keys": []
"keys": [],
"last_read_line_id": -1
}
]
----
@@ -657,7 +660,8 @@ HTTP/1.1 200 OK
"message": "Учитани додаци: alias, buflist, charset, exec, fifo, fset, guile, irc, javascript, logger, lua, perl, php, python, relay, ruby, script, spell, tcl, trigger, typing, xfer",
"tags": []
}
]
],
"last_read_line_id": -1
}
----
@@ -704,6 +708,7 @@ HTTP/1.1 200 OK
"host": "~alice@example.com"
},
"keys": [],
"last_read_line_id": -1,
"nicklist_root": {
"id": 0,
"parent_group_id": -1,
@@ -902,7 +907,8 @@ HTTP/1.1 200 OK
"key": "up",
"command": "/fset -up"
}
]
],
"last_read_line_id": -1
}
----
+22
View File
@@ -350,9 +350,13 @@ relay_api_msg_buffer_to_json (struct t_gui_buffer *buffer,
{
struct t_hdata *hdata;
struct t_gui_buffer *pointer;
struct t_gui_lines *ptr_lines;
struct t_gui_line *ptr_line;
struct t_gui_line_data *ptr_line_data;
cJSON *json, *json_local_vars, *json_lines, *json_nicklist_root;
const char *ptr_string;
char *string;
int last_read_line_id;
hdata = relay_hdata_buffer;
pointer = buffer;
@@ -405,6 +409,24 @@ relay_api_msg_buffer_to_json (struct t_gui_buffer *buffer,
if (json_lines)
cJSON_AddItemToObject (json, "lines", json_lines);
}
last_read_line_id = -1;
ptr_lines = weechat_hdata_pointer (relay_hdata_buffer, buffer, "own_lines");
if (ptr_lines)
{
ptr_line = weechat_hdata_pointer (relay_hdata_lines, ptr_lines, "last_read_line");
if (ptr_line)
{
ptr_line_data = weechat_hdata_pointer (relay_hdata_line, ptr_line, "data");
if (ptr_line_data)
{
last_read_line_id = weechat_hdata_integer (relay_hdata_line_data,
ptr_line_data, "id");
}
}
}
cJSON_AddItemToObject (
json, "last_read_line_id",
cJSON_CreateNumber (last_read_line_id));
/* nicks */
if (nicks)
+2 -2
View File
@@ -26,8 +26,8 @@ struct t_relay_client;
enum t_relay_status;
#define RELAY_API_VERSION_MAJOR 0
#define RELAY_API_VERSION_MINOR 4
#define RELAY_API_VERSION_PATCH 1
#define RELAY_API_VERSION_MINOR 5
#define RELAY_API_VERSION_PATCH 0
#define RELAY_API_VERSION_NUMBER \
((RELAY_API_VERSION_MAJOR << 16) \
+ (RELAY_API_VERSION_MINOR << 8) \
+6 -1
View File
@@ -17,7 +17,7 @@ info:
license:
name: CC BY-NC-SA 4.0
url: https://creativecommons.org/licenses/by-nc-sa/4.0/
version: 0.4.1
version: 0.5.0
externalDocs:
url: https://weechat.org/doc/
@@ -1043,6 +1043,11 @@ components:
type: array
items:
$ref: '#/components/schemas/Line'
last_read_line_id:
type: integer
format: int64
description: identifier of the last line read in the buffer (-1 if read marker is not displayed)
example: -1
nicklist_root:
$ref: '#/components/schemas/NickGroup'
required:
@@ -177,6 +177,7 @@ TEST(RelayApiMsg, BufferToJson)
WEE_CHECK_OBJ_STR("core", json_local_vars, "plugin");
WEE_CHECK_OBJ_STR("weechat", json_local_vars, "name");
POINTERS_EQUAL(NULL, cJSON_GetObjectItem (json, "lines"));
WEE_CHECK_OBJ_NUM(-1, json, "last_read_line_id");
POINTERS_EQUAL(NULL, cJSON_GetObjectItem (json, "nicks"));
cJSON_Delete (json);