summaryrefslogtreecommitdiff
path: root/src/plugins/relay
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2024-03-10 14:28:44 +0100
committerSébastien Helleu <flashcode@flashtux.org>2024-03-12 20:37:52 +0100
commitbb346f8c6c62655a6ef8fe4bc848d179258ce008 (patch)
treeae39e41292cb6304da407bcdc589f9100fac956a /src/plugins/relay
parent48ca390f79de87689b2ce63c830bf19377907583 (diff)
downloadweechat-bb346f8c6c62655a6ef8fe4bc848d179258ce008.zip
relay/api: replace "context" by "buffer_id" (issue #2081)
Diffstat (limited to 'src/plugins/relay')
-rw-r--r--src/plugins/relay/api/relay-api-msg.c27
-rw-r--r--src/plugins/relay/api/relay-api-msg.h2
-rw-r--r--src/plugins/relay/api/relay-api-protocol.c26
3 files changed, 27 insertions, 28 deletions
diff --git a/src/plugins/relay/api/relay-api-msg.c b/src/plugins/relay/api/relay-api-msg.c
index 4a5bfdfbc..6dde683a5 100644
--- a/src/plugins/relay/api/relay-api-msg.c
+++ b/src/plugins/relay/api/relay-api-msg.c
@@ -116,13 +116,15 @@ relay_api_msg_send_json_internal (struct t_relay_client *client,
const char *message,
const char *event_name,
const char *event_type,
- const char *event_context,
+ struct t_gui_buffer *event_buffer,
const char *headers,
cJSON *json_body)
{
cJSON *json, *json_event;
int num_bytes;
- char *string;
+ const char *ptr_id;
+ char *string, *error;
+ long long id;
if (!client || !message)
return -1;
@@ -151,9 +153,18 @@ relay_api_msg_send_json_internal (struct t_relay_client *client,
cJSON_AddItemToObject (
json_event, "type",
cJSON_CreateString ((event_type) ? event_type : ""));
+ id = -1;
+ if (event_buffer)
+ {
+ ptr_id = weechat_buffer_get_string (event_buffer, "id");
+ error = NULL;
+ id = strtoll (ptr_id, &error, 10);
+ if (!error || error[0])
+ id = -1;
+ }
cJSON_AddItemToObject (
- json_event, "context",
- cJSON_CreateString ((event_context) ? event_context : ""));
+ json_event, "buffer_id",
+ cJSON_CreateNumber (id));
cJSON_AddItemToObject (json, "event", json_event);
}
}
@@ -200,7 +211,7 @@ relay_api_msg_send_json (struct t_relay_client *client,
message,
NULL, /* event_name */
NULL, /* event_type */
- NULL, /* event_context */
+ NULL, /* event_buffer */
NULL, /* headers */
json_body);
}
@@ -247,7 +258,7 @@ relay_api_msg_send_error_json (struct t_relay_client *client,
message,
NULL, /* event_name */
NULL, /* event_type */
- NULL, /* event_context */
+ NULL, /* event_buffer */
headers,
json);
cJSON_Delete (json);
@@ -285,14 +296,14 @@ int
relay_api_msg_send_event (struct t_relay_client *client,
const char *name,
const char *type,
- const char *context,
+ struct t_gui_buffer *buffer,
cJSON *json_body)
{
return relay_api_msg_send_json_internal (client,
RELAY_API_HTTP_0_EVENT,
name,
type,
- context,
+ buffer,
NULL, /* headers */
json_body);
}
diff --git a/src/plugins/relay/api/relay-api-msg.h b/src/plugins/relay/api/relay-api-msg.h
index 8a2b7835c..33f0dd690 100644
--- a/src/plugins/relay/api/relay-api-msg.h
+++ b/src/plugins/relay/api/relay-api-msg.h
@@ -34,7 +34,7 @@ extern int relay_api_msg_send_error_json (struct t_relay_client *client,
extern int relay_api_msg_send_event (struct t_relay_client *client,
const char *name,
const char *type,
- const char *context,
+ struct t_gui_buffer *buffer,
cJSON *json_body);
extern cJSON *relay_api_msg_buffer_to_json (struct t_gui_buffer *buffer,
long lines,
diff --git a/src/plugins/relay/api/relay-api-protocol.c b/src/plugins/relay/api/relay-api-protocol.c
index 70f3cc9c3..cdfa25516 100644
--- a/src/plugins/relay/api/relay-api-protocol.c
+++ b/src/plugins/relay/api/relay-api-protocol.c
@@ -103,7 +103,7 @@ relay_api_protocol_signal_buffer_cb (const void *pointer, void *data,
ptr_buffer, lines, 0, RELAY_API_DATA(ptr_client, sync_colors));
if (json)
{
- relay_api_msg_send_event (ptr_client, signal, "buffer", "", json);
+ relay_api_msg_send_event (ptr_client, signal, "buffer", NULL, json);
cJSON_Delete (json);
}
}
@@ -127,12 +127,8 @@ relay_api_protocol_signal_buffer_cb (const void *pointer, void *data,
ptr_line_data, RELAY_API_DATA(ptr_client, sync_colors));
if (json)
{
- relay_api_msg_send_event (
- ptr_client,
- signal,
- "line",
- weechat_buffer_get_string (ptr_buffer, "full_name"),
- json);
+ relay_api_msg_send_event (ptr_client, signal, "line", ptr_buffer,
+ json);
cJSON_Delete (json);
}
}
@@ -178,12 +174,8 @@ relay_api_protocol_hsignal_nicklist_cb (const void *pointer, void *data,
json = relay_api_msg_nick_group_to_json (ptr_group);
if (json)
{
- relay_api_msg_send_event (
- ptr_client,
- signal,
- "nick_group",
- weechat_buffer_get_string (ptr_buffer, "full_name"),
- json);
+ relay_api_msg_send_event (ptr_client, signal, "nick_group",
+ ptr_buffer, json);
cJSON_Delete (json);
}
}
@@ -194,12 +186,8 @@ relay_api_protocol_hsignal_nicklist_cb (const void *pointer, void *data,
json = relay_api_msg_nick_to_json (ptr_nick);
if (json)
{
- relay_api_msg_send_event (
- ptr_client,
- signal,
- "nick",
- weechat_buffer_get_string (ptr_buffer, "full_name"),
- json);
+ relay_api_msg_send_event (ptr_client, signal, "nick", ptr_buffer,
+ json);
cJSON_Delete (json);
}
}