aboutsummaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
authorOliver <zen@noreply.codeberg.org>2025-07-16 20:21:20 +0200
committerOliver <zen@noreply.codeberg.org>2025-07-16 20:21:20 +0200
commit3554a73aa50526631961efcca78c6c8eb2a16911 (patch)
treefc4c21a65337ab8ecb4fb00aa551ee21997faf6f /activitypub.c
parentd6973cf43adfd67000e76eed26fadea7c265a09c (diff)
parenta2518f5d70b19f9cafd860bd6cde22399c452b60 (diff)
Merge pull request 'master' (#9) from grunfink/snac2:master into master
Reviewed-on: https://codeberg.org/zen/snac2/pulls/9
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/activitypub.c b/activitypub.c
index 120b4a1..100db67 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(v);
xs *h = xs_fmt("%s?t=%s", srv_baseurl, n + 1);
xs *l = xs_fmt("<a href=\"%s\" class=\"mention hashtag\" rel=\"tag\">%s</a>", h, v);
@@ -2766,6 +2766,39 @@ void process_user_queue_item(snac *user, xs_dict *q_item)
}
}
else
+ if (strcmp(type, "notify_webhook") == 0) {
+ const char *webhook = xs_dict_get(user->config, "notify_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"));
+
+ 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));
}
@@ -3050,6 +3083,10 @@ void process_queue_item(xs_dict *q_item)
}
}
else
+ if (strcmp(type, "rss_hashtag_poll") == 0) {
+ rss_poll_hashtags();
+ }
+ else
srv_log(xs_fmt("unexpected q_item type '%s'", type));
}