From 24105f6e9759b74c04522de1de12ddb77cfba568 Mon Sep 17 00:00:00 2001 From: postscriptum Date: Thu, 22 May 2025 03:34:48 +0300 Subject: use utf-8 lowercase function for tags #396 --- activitypub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index a7e133a..3ff51ad 100644 --- a/activitypub.c +++ b/activitypub.c @@ -903,7 +903,7 @@ xs_str *process_tags(snac *snac, const char *content, xs_list **tag) if (*v == '#') { /* hashtag */ xs *d = xs_dict_new(); - xs *n = xs_tolower_i(xs_dup(v)); + xs *n = xs_utf8_to_lower(xs_dup(v)); xs *h = xs_fmt("%s?t=%s", srv_baseurl, n + 1); xs *l = xs_fmt("%s", h, v); -- cgit v1.2.3 From 56816b305155fee2154c7991ba9be8c0e7671307 Mon Sep 17 00:00:00 2001 From: grunfink Date: Thu, 22 May 2025 11:18:48 +0200 Subject: Minor memory leak fixes. --- activitypub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index c06d8df..0cc7bcb 100644 --- a/activitypub.c +++ b/activitypub.c @@ -903,7 +903,7 @@ xs_str *process_tags(snac *snac, const char *content, xs_list **tag) if (*v == '#') { /* hashtag */ xs *d = xs_dict_new(); - xs *n = xs_utf8_to_lower(xs_dup(v)); + xs *n = xs_utf8_to_lower(v); xs *h = xs_fmt("%s?t=%s", srv_baseurl, n + 1); xs *l = xs_fmt("%s", h, v); -- cgit v1.2.3 From a1369b39c1bd3d2036af12368997648454ca5564 Mon Sep 17 00:00:00 2001 From: grunfink Date: Wed, 28 May 2025 09:07:19 +0200 Subject: Activated hashtag RSS polling. --- activitypub.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index 0cc7bcb..2cffeac 100644 --- a/activitypub.c +++ b/activitypub.c @@ -3049,6 +3049,10 @@ void process_queue_item(xs_dict *q_item) } } } + else + if (strcmp(type, "rss_poll") == 0) { + rss_poll_hashtags(); + } else srv_log(xs_fmt("unexpected q_item type '%s'", type)); } -- cgit v1.2.3 From 0594197af7a4a11795150a85fafa7fa5bc6fc4f5 Mon Sep 17 00:00:00 2001 From: grunfink Date: Wed, 28 May 2025 09:16:23 +0200 Subject: Renamed server knob to 'rss_hashtag_poll_hours'. --- activitypub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index 2cffeac..8877a27 100644 --- a/activitypub.c +++ b/activitypub.c @@ -3050,7 +3050,7 @@ void process_queue_item(xs_dict *q_item) } } else - if (strcmp(type, "rss_poll") == 0) { + if (strcmp(type, "rss_hashtag_poll") == 0) { rss_poll_hashtags(); } else -- cgit v1.2.3 From 5a2aef8666a82a30dff329992bd41baa53d4e123 Mon Sep 17 00:00:00 2001 From: grunfink Date: Fri, 30 May 2025 12:12:19 +0200 Subject: More notify_webhook work. --- activitypub.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index 8877a27..fb0c42c 100644 --- a/activitypub.c +++ b/activitypub.c @@ -2765,6 +2765,39 @@ void process_user_queue_item(snac *user, xs_dict *q_item) snac_log(user, xs_fmt("actor_refresh %s %d", actor, status)); } } + else + if (strcmp(type, "notify_webhook") == 0) { + const char *webhook = xs_dict_get(user->config, "notify_webhook"); + + if (xs_is_string(webhook)) { + const xs_dict *msg = xs_dict_get(q_item, "message"); + int retries = xs_number_get(xs_dict_get(q_item, "retries")); + + xs *hdrs = xs_dict_new(); + + hdrs = xs_dict_set(hdrs, "content-type", "application/json"); + hdrs = xs_dict_set(hdrs, "user-agent", USER_AGENT); + + xs *body = xs_json_dumps(msg, 4); + + int status; + xs *rsp = xs_http_request("POST", webhook, hdrs, body, strlen(body), &status, NULL, NULL, 0); + + snac_debug(user, 0, xs_fmt("webhook post %s %d", webhook, status)); + + if (!valid_status(status)) { + retries++; + + if (retries > queue_retry_max) + snac_debug(user, 0, xs_fmt("webhook post giving up %s", webhook)); + else { + snac_debug(user, 0, xs_fmt("webhook post requeue %s %d", webhook, retries)); + + enqueue_notify_webhook(user, msg, retries); + } + } + } + } else snac_log(user, xs_fmt("unexpected user q_item type '%s'", type)); } -- cgit v1.2.3 From f055c8b694a398868d14fd70df61d02429846dae Mon Sep 17 00:00:00 2001 From: grunfink Date: Fri, 30 May 2025 19:34:11 +0200 Subject: Added a new server knob disable_notify_webhook. --- activitypub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index fb0c42c..ab63abe 100644 --- a/activitypub.c +++ b/activitypub.c @@ -2769,7 +2769,7 @@ void process_user_queue_item(snac *user, xs_dict *q_item) if (strcmp(type, "notify_webhook") == 0) { const char *webhook = xs_dict_get(user->config, "notify_webhook"); - if (xs_is_string(webhook)) { + if (xs_is_string(webhook) && *webhook) { const xs_dict *msg = xs_dict_get(q_item, "message"); int retries = xs_number_get(xs_dict_get(q_item, "retries")); -- cgit v1.2.3 From c8848f6e9f8e9fd9d17290b1ef301d3bf7beccb4 Mon Sep 17 00:00:00 2001 From: grunfink Date: Fri, 30 May 2025 19:59:40 +0200 Subject: More webhook checks. --- activitypub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activitypub.c') diff --git a/activitypub.c b/activitypub.c index ab63abe..100db67 100644 --- a/activitypub.c +++ b/activitypub.c @@ -2769,7 +2769,7 @@ void process_user_queue_item(snac *user, xs_dict *q_item) if (strcmp(type, "notify_webhook") == 0) { const char *webhook = xs_dict_get(user->config, "notify_webhook"); - if (xs_is_string(webhook) && *webhook) { + if (xs_is_string(webhook) && xs_match(webhook, "https://*|http://*")) { /** **/ const xs_dict *msg = xs_dict_get(q_item, "message"); int retries = xs_number_get(xs_dict_get(q_item, "retries")); -- cgit v1.2.3