summaryrefslogtreecommitdiff
path: root/src/plugins/relay/api
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2024-04-07 10:26:42 +0200
committerSébastien Helleu <flashcode@flashtux.org>2024-04-07 13:18:14 +0200
commit7c2f44e74ec36068bfb80aecb70af750de6ec9fa (patch)
tree876a304d3c42edadd4338c7cb327f144860d01db /src/plugins/relay/api
parent89fe540b531705d8455685173c692522e81cd134 (diff)
downloadweechat-7c2f44e74ec36068bfb80aecb70af750de6ec9fa.zip
relay/api: add nicklist group and nick id in response to GET /api/buffers (issue #2081)
Diffstat (limited to 'src/plugins/relay/api')
-rw-r--r--src/plugins/relay/api/relay-api-msg.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/plugins/relay/api/relay-api-msg.c b/src/plugins/relay/api/relay-api-msg.c
index a1bc019b9..5b48b50a2 100644
--- a/src/plugins/relay/api/relay-api-msg.c
+++ b/src/plugins/relay/api/relay-api-msg.c
@@ -557,6 +557,7 @@ relay_api_msg_nick_to_json (struct t_gui_nick *nick)
{
struct t_hdata *hdata;
struct t_gui_nick *pointer;
+ struct t_gui_nick_group *ptr_group;
cJSON *json;
const char *ptr_string;
@@ -570,6 +571,13 @@ relay_api_msg_nick_to_json (struct t_gui_nick *nick)
if (!nick)
return json;
+ MSG_ADD_HDATA_VAR(Number, "id", longlong, "id");
+ ptr_group = weechat_hdata_pointer (relay_hdata_nick, nick, "group");
+ cJSON_AddItemToObject (
+ json, "parent_group_id",
+ cJSON_CreateNumber (
+ (ptr_group) ?
+ weechat_hdata_longlong (relay_hdata_nick_group, ptr_group, "id") : -1));
MSG_ADD_HDATA_STR("prefix", "prefix");
MSG_ADD_HDATA_STR("prefix_color", "prefix_color");
MSG_ADD_HDATA_STR("name", "name");
@@ -587,11 +595,10 @@ cJSON *
relay_api_msg_nick_group_to_json (struct t_gui_nick_group *nick_group)
{
struct t_hdata *hdata;
- struct t_gui_nick_group *pointer;
+ struct t_gui_nick_group *pointer, *ptr_group;
+ struct t_gui_nick *ptr_nick;
cJSON *json, *json_groups, *json_nicks;
const char *ptr_string;
- struct t_gui_nick_group *ptr_group;
- struct t_gui_nick *ptr_nick;
hdata = relay_hdata_nick_group;
pointer = nick_group;
@@ -603,6 +610,13 @@ relay_api_msg_nick_group_to_json (struct t_gui_nick_group *nick_group)
if (!nick_group)
return json;
+ MSG_ADD_HDATA_VAR(Number, "id", longlong, "id");
+ ptr_group = weechat_hdata_pointer (relay_hdata_nick_group, nick_group, "parent");
+ cJSON_AddItemToObject (
+ json, "parent_group_id",
+ cJSON_CreateNumber (
+ (ptr_group) ?
+ weechat_hdata_longlong (relay_hdata_nick_group, ptr_group, "id") : -1));
MSG_ADD_HDATA_STR("name", "name");
MSG_ADD_HDATA_STR("color", "color");
MSG_ADD_HDATA_VAR(Bool, "visible", integer, "visible");