diff options
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/activitypub.c b/activitypub.c index 59df31a..8eb7844 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* snac - A simple, minimalistic ActivityPub instance */ | 1 | /* snac - A simple, minimalistic ActivityPub instance */ |
| 2 | /* copyright (c) 2022 - 2025 grunfink et al. / MIT license */ | 2 | /* copyright (c) 2022 - 2026 grunfink et al. / MIT license */ |
| 3 | 3 | ||
| 4 | #include "xs.h" | 4 | #include "xs.h" |
| 5 | #include "xs_json.h" | 5 | #include "xs_json.h" |
| @@ -17,6 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | #include "snac.h" | 18 | #include "snac.h" |
| 19 | 19 | ||
| 20 | #include <stddef.h> | ||
| 20 | #include <sys/wait.h> | 21 | #include <sys/wait.h> |
| 21 | 22 | ||
| 22 | const char * const public_address = "https:/" "/www.w3.org/ns/activitystreams#Public"; | 23 | const char * const public_address = "https:/" "/www.w3.org/ns/activitystreams#Public"; |
| @@ -1611,7 +1612,7 @@ xs_dict *msg_emoji_init(snac *snac, const char *mid, const char *eid_o) | |||
| 1611 | xs *dict = xs_dict_new(); | 1612 | xs *dict = xs_dict_new(); |
| 1612 | xs *icon = xs_dict_new(); | 1613 | xs *icon = xs_dict_new(); |
| 1613 | xs *accounts = xs_list_new(); | 1614 | xs *accounts = xs_list_new(); |
| 1614 | xs *emjs = emojis(); | 1615 | xs *emjs = emojis_rm_categories(); |
| 1615 | 1616 | ||
| 1616 | /* may be a default emoji */ | 1617 | /* may be a default emoji */ |
| 1617 | xs *eidd = xs_dup(eid); | 1618 | xs *eidd = xs_dup(eid); |
| @@ -2321,9 +2322,17 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach, | |||
| 2321 | /* creates a Question message */ | 2322 | /* creates a Question message */ |
| 2322 | { | 2323 | { |
| 2323 | xs_dict *msg = msg_note(user, content, NULL, NULL, attach, 0, NULL, NULL); | 2324 | xs_dict *msg = msg_note(user, content, NULL, NULL, attach, 0, NULL, NULL); |
| 2324 | int max = 8; | 2325 | const xs_number *max_options = xs_dict_get(srv_config, "max_poll_options"); |
| 2326 | const xs_number *max_length = xs_dict_get(srv_config, "max_poll_option_length"); | ||
| 2325 | xs_set seen; | 2327 | xs_set seen; |
| 2326 | 2328 | ||
| 2329 | size_t max_line = 60; | ||
| 2330 | int max = 8; | ||
| 2331 | if (xs_type(max_options) == XSTYPE_NUMBER) | ||
| 2332 | max = xs_number_get(max_options); | ||
| 2333 | if (xs_type(max_length) == XSTYPE_NUMBER) | ||
| 2334 | max_line = xs_number_get(max_length); | ||
| 2335 | |||
| 2327 | msg = xs_dict_set(msg, "type", "Question"); | 2336 | msg = xs_dict_set(msg, "type", "Question"); |
| 2328 | 2337 | ||
| 2329 | /* make it non-editable */ | 2338 | /* make it non-editable */ |
| @@ -2341,8 +2350,8 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach, | |||
| 2341 | xs *v2 = xs_dup(v); | 2350 | xs *v2 = xs_dup(v); |
| 2342 | xs *d = xs_dict_new(); | 2351 | xs *d = xs_dict_new(); |
| 2343 | 2352 | ||
| 2344 | if (strlen(v2) > 60) { | 2353 | if (strlen(v2) > max_line) { |
| 2345 | v2[60] = '\0'; | 2354 | v2[max_line] = '\0'; |
| 2346 | v2 = xs_str_cat(v2, "..."); | 2355 | v2 = xs_str_cat(v2, "..."); |
| 2347 | } | 2356 | } |
| 2348 | 2357 | ||
| @@ -2578,6 +2587,11 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req) | |||
| 2578 | return -1; | 2587 | return -1; |
| 2579 | } | 2588 | } |
| 2580 | 2589 | ||
| 2590 | if (strcmp(type, "EmojiReact") == 0 && xs_is_true(xs_dict_get(srv_config, "disable_emojireact"))) { | ||
| 2591 | srv_log(xs_fmt("Dropping EmojiReact from %s due to admin configuration", actor)); | ||
| 2592 | return -1; | ||
| 2593 | } | ||
| 2594 | |||
| 2581 | const char *object, *utype; | 2595 | const char *object, *utype; |
| 2582 | 2596 | ||
| 2583 | object = xs_dict_get(msg, "object"); | 2597 | object = xs_dict_get(msg, "object"); |
| @@ -2953,7 +2967,7 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req) | |||
| 2953 | if (xs_is_null(object)) | 2967 | if (xs_is_null(object)) |
| 2954 | snac_log(snac, xs_fmt("malformed message: no 'id' field")); | 2968 | snac_log(snac, xs_fmt("malformed message: no 'id' field")); |
| 2955 | else | 2969 | else |
| 2956 | if (timeline_admire(snac, object, actor, 1, xs_dup(msg)) == HTTP_STATUS_CREATED) | 2970 | if (timeline_admire(snac, object, actor, 1, msg) == HTTP_STATUS_CREATED) |
| 2957 | snac_log(snac, xs_fmt("new '%s' %s %s", type, actor, object)); | 2971 | snac_log(snac, xs_fmt("new '%s' %s %s", type, actor, object)); |
| 2958 | else | 2972 | else |
| 2959 | snac_log(snac, xs_fmt("repeated '%s' from %s to %s", type, actor, object)); | 2973 | snac_log(snac, xs_fmt("repeated '%s' from %s to %s", type, actor, object)); |
| @@ -3390,7 +3404,7 @@ void process_user_queue_item(snac *user, xs_dict *q_item) | |||
| 3390 | actor_add(actor, actor_o); | 3404 | actor_add(actor, actor_o); |
| 3391 | } | 3405 | } |
| 3392 | else { | 3406 | else { |
| 3393 | if (status == HTTP_STATUS_GONE) { | 3407 | if (status == HTTP_STATUS_GONE || status == HTTP_STATUS_NOT_FOUND) { |
| 3394 | actor_failure(actor, 1); | 3408 | actor_failure(actor, 1); |
| 3395 | snac_log(user, xs_fmt("actor_refresh marking actor %s as broken %d", actor, status)); | 3409 | snac_log(user, xs_fmt("actor_refresh marking actor %s as broken %d", actor, status)); |
| 3396 | } | 3410 | } |