diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2024-04-10 20:57:16 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2024-04-10 20:57:16 +0200 |
commit | f40f3cfa40be2d627153df2c1dce924fdbf03104 (patch) | |
tree | e3dbff72d7ea337b6b4d31c3df5fe0ab57bfd6a2 /src | |
parent | 5046a9b596018c50ba295014aa957926937557bd (diff) | |
download | weechat-f40f3cfa40be2d627153df2c1dce924fdbf03104.zip |
relay/api: add tags in lines displayed in remote buffers
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/relay/api/remote/relay-remote-event.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/plugins/relay/api/remote/relay-remote-event.c b/src/plugins/relay/api/remote/relay-remote-event.c index 2ab445be0..46239d58c 100644 --- a/src/plugins/relay/api/remote/relay-remote-event.c +++ b/src/plugins/relay/api/remote/relay-remote-event.c @@ -129,8 +129,9 @@ relay_remote_event_get_buffer_id (struct t_gui_buffer *buffer) RELAY_REMOTE_EVENT_CALLBACK(line) { - cJSON *json_obj; + cJSON *json_obj, *json_tags, *json_tag; const char *date, *prefix, *message; + char **tags; struct timeval tv_date; if (!event->buffer) @@ -146,16 +147,35 @@ RELAY_REMOTE_EVENT_CALLBACK(line) tv_date.tv_usec = 0; } + tags = weechat_string_dyn_alloc (256); + if (tags) + { + json_tags = cJSON_GetObjectItem (event->json, "tags"); + if (json_tags && cJSON_IsArray (json_tags)) + { + cJSON_ArrayForEach (json_tag, json_tags) + { + if (*tags[0]) + weechat_string_dyn_concat (tags, ",", -1); + weechat_string_dyn_concat ( + tags, cJSON_GetStringValue (json_tag), -1); + } + } + } + weechat_printf_datetime_tags ( event->buffer, tv_date.tv_sec, tv_date.tv_usec, - NULL, + (tags) ? *tags : NULL, "%s%s%s", (prefix && prefix[0]) ? prefix : "", (prefix && prefix[0]) ? "\t" : "", message); + if (tags) + weechat_string_dyn_free (tags, 1); + return WEECHAT_RC_OK; } |