From 8949a65f526e54f67f8a6d4637850eee0dbc1a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 18 May 2024 09:51:39 +0200 Subject: [PATCH] relay/remote: fix highlight on lines received from remote --- .../relay/api/remote/relay-remote-event.c | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/plugins/relay/api/remote/relay-remote-event.c b/src/plugins/relay/api/remote/relay-remote-event.c index 60de6f88c..01ec8f95f 100644 --- a/src/plugins/relay/api/remote/relay-remote-event.c +++ b/src/plugins/relay/api/remote/relay-remote-event.c @@ -134,9 +134,9 @@ relay_remote_event_get_buffer_id (struct t_gui_buffer *buffer) RELAY_REMOTE_EVENT_CALLBACK(line) { cJSON *json_obj, *json_tags, *json_tag; - const char *date, *prefix, *message; + const char *date, *prefix, *message, *ptr_tag; char **tags; - int y; + int y, highlight, tag_notify_highlight; struct timeval tv_date; if (!event->buffer || !event->json) @@ -144,6 +144,7 @@ RELAY_REMOTE_EVENT_CALLBACK(line) JSON_GET_NUM(event->json, y, -1); JSON_GET_STR(event->json, date); + JSON_GET_BOOL(event->json, highlight); JSON_GET_STR(event->json, prefix); JSON_GET_STR(event->json, message); @@ -153,6 +154,8 @@ RELAY_REMOTE_EVENT_CALLBACK(line) tv_date.tv_usec = 0; } + tag_notify_highlight = 0; + tags = weechat_string_dyn_alloc (256); if (tags) { @@ -161,12 +164,29 @@ RELAY_REMOTE_EVENT_CALLBACK(line) { 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); + ptr_tag = cJSON_GetStringValue (json_tag); + if (ptr_tag) + { + if (*tags[0]) + weechat_string_dyn_concat (tags, ",", -1); + if (highlight && (strncmp (ptr_tag, "notify_", 7) == 0)) + { + weechat_string_dyn_concat (tags, "notify_highlight", -1); + tag_notify_highlight = 1; + } + else + { + weechat_string_dyn_concat (tags, ptr_tag, -1); + } + } } } + if (highlight && !tag_notify_highlight) + { + if (*tags[0]) + weechat_string_dyn_concat (tags, ",", -1); + weechat_string_dyn_concat (tags, "notify_highlight", -1); + } } if (y >= 0)