diff options
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 39 |
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) | |||
| 903 | if (*v == '#') { | 903 | if (*v == '#') { |
| 904 | /* hashtag */ | 904 | /* hashtag */ |
| 905 | xs *d = xs_dict_new(); | 905 | xs *d = xs_dict_new(); |
| 906 | xs *n = xs_tolower_i(xs_dup(v)); | 906 | xs *n = xs_utf8_to_lower(v); |
| 907 | xs *h = xs_fmt("%s?t=%s", srv_baseurl, n + 1); | 907 | xs *h = xs_fmt("%s?t=%s", srv_baseurl, n + 1); |
| 908 | xs *l = xs_fmt("<a href=\"%s\" class=\"mention hashtag\" rel=\"tag\">%s</a>", h, v); | 908 | xs *l = xs_fmt("<a href=\"%s\" class=\"mention hashtag\" rel=\"tag\">%s</a>", h, v); |
| 909 | 909 | ||
| @@ -2766,6 +2766,39 @@ void process_user_queue_item(snac *user, xs_dict *q_item) | |||
| 2766 | } | 2766 | } |
| 2767 | } | 2767 | } |
| 2768 | else | 2768 | else |
| 2769 | if (strcmp(type, "notify_webhook") == 0) { | ||
| 2770 | const char *webhook = xs_dict_get(user->config, "notify_webhook"); | ||
| 2771 | |||
| 2772 | if (xs_is_string(webhook) && xs_match(webhook, "https://*|http://*")) { /** **/ | ||
| 2773 | const xs_dict *msg = xs_dict_get(q_item, "message"); | ||
| 2774 | int retries = xs_number_get(xs_dict_get(q_item, "retries")); | ||
| 2775 | |||
| 2776 | xs *hdrs = xs_dict_new(); | ||
| 2777 | |||
| 2778 | hdrs = xs_dict_set(hdrs, "content-type", "application/json"); | ||
| 2779 | hdrs = xs_dict_set(hdrs, "user-agent", USER_AGENT); | ||
| 2780 | |||
| 2781 | xs *body = xs_json_dumps(msg, 4); | ||
| 2782 | |||
| 2783 | int status; | ||
| 2784 | xs *rsp = xs_http_request("POST", webhook, hdrs, body, strlen(body), &status, NULL, NULL, 0); | ||
| 2785 | |||
| 2786 | snac_debug(user, 0, xs_fmt("webhook post %s %d", webhook, status)); | ||
| 2787 | |||
| 2788 | if (!valid_status(status)) { | ||
| 2789 | retries++; | ||
| 2790 | |||
| 2791 | if (retries > queue_retry_max) | ||
| 2792 | snac_debug(user, 0, xs_fmt("webhook post giving up %s", webhook)); | ||
| 2793 | else { | ||
| 2794 | snac_debug(user, 0, xs_fmt("webhook post requeue %s %d", webhook, retries)); | ||
| 2795 | |||
| 2796 | enqueue_notify_webhook(user, msg, retries); | ||
| 2797 | } | ||
| 2798 | } | ||
| 2799 | } | ||
| 2800 | } | ||
| 2801 | else | ||
| 2769 | snac_log(user, xs_fmt("unexpected user q_item type '%s'", type)); | 2802 | snac_log(user, xs_fmt("unexpected user q_item type '%s'", type)); |
| 2770 | } | 2803 | } |
| 2771 | 2804 | ||
| @@ -3050,6 +3083,10 @@ void process_queue_item(xs_dict *q_item) | |||
| 3050 | } | 3083 | } |
| 3051 | } | 3084 | } |
| 3052 | else | 3085 | else |
| 3086 | if (strcmp(type, "rss_hashtag_poll") == 0) { | ||
| 3087 | rss_poll_hashtags(); | ||
| 3088 | } | ||
| 3089 | else | ||
| 3053 | srv_log(xs_fmt("unexpected q_item type '%s'", type)); | 3090 | srv_log(xs_fmt("unexpected q_item type '%s'", type)); |
| 3054 | } | 3091 | } |
| 3055 | 3092 | ||