summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/activitypub.c b/activitypub.c
index 5e55b8a..0535269 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -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
22const char * const public_address = "https:/" "/www.w3.org/ns/activitystreams#Public"; 23const 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);
@@ -1920,6 +1921,9 @@ xs_dict *msg_actor(snac *snac)
1920 if (xs_type(location) == XSTYPE_DICT) 1921 if (xs_type(location) == XSTYPE_DICT)
1921 msg = xs_dict_set(msg, "location", location); 1922 msg = xs_dict_set(msg, "location", location);
1922 1923
1924 xs *webfinger = xs_fmt("%s@%s", snac->uid, xs_dict_get(srv_config, "host"));
1925 msg = xs_dict_set(msg, "webfinger", webfinger);
1926
1923 /* cache it */ 1927 /* cache it */
1924 snac_debug(snac, 1, xs_fmt("Caching actor %s", snac->actor)); 1928 snac_debug(snac, 1, xs_fmt("Caching actor %s", snac->actor));
1925 object_add_ow(snac->actor, msg); 1929 object_add_ow(snac->actor, msg);
@@ -2321,9 +2325,17 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach,
2321/* creates a Question message */ 2325/* creates a Question message */
2322{ 2326{
2323 xs_dict *msg = msg_note(user, content, NULL, NULL, attach, 0, NULL, NULL); 2327 xs_dict *msg = msg_note(user, content, NULL, NULL, attach, 0, NULL, NULL);
2324 int max = 8; 2328 const xs_number *max_options = xs_dict_get(srv_config, "max_poll_options");
2329 const xs_number *max_length = xs_dict_get(srv_config, "max_poll_option_length");
2325 xs_set seen; 2330 xs_set seen;
2326 2331
2332 size_t max_line = 60;
2333 int max = 8;
2334 if (xs_type(max_options) == XSTYPE_NUMBER)
2335 max = xs_number_get(max_options);
2336 if (xs_type(max_length) == XSTYPE_NUMBER)
2337 max_line = xs_number_get(max_length);
2338
2327 msg = xs_dict_set(msg, "type", "Question"); 2339 msg = xs_dict_set(msg, "type", "Question");
2328 2340
2329 /* make it non-editable */ 2341 /* make it non-editable */
@@ -2341,8 +2353,8 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach,
2341 xs *v2 = xs_dup(v); 2353 xs *v2 = xs_dup(v);
2342 xs *d = xs_dict_new(); 2354 xs *d = xs_dict_new();
2343 2355
2344 if (strlen(v2) > 60) { 2356 if (strlen(v2) > max_line) {
2345 v2[60] = '\0'; 2357 v2[max_line] = '\0';
2346 v2 = xs_str_cat(v2, "..."); 2358 v2 = xs_str_cat(v2, "...");
2347 } 2359 }
2348 2360
@@ -2958,7 +2970,7 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req)
2958 if (xs_is_null(object)) 2970 if (xs_is_null(object))
2959 snac_log(snac, xs_fmt("malformed message: no 'id' field")); 2971 snac_log(snac, xs_fmt("malformed message: no 'id' field"));
2960 else 2972 else
2961 if (timeline_admire(snac, object, actor, 1, xs_dup(msg)) == HTTP_STATUS_CREATED) 2973 if (timeline_admire(snac, object, actor, 1, msg) == HTTP_STATUS_CREATED)
2962 snac_log(snac, xs_fmt("new '%s' %s %s", type, actor, object)); 2974 snac_log(snac, xs_fmt("new '%s' %s %s", type, actor, object));
2963 else 2975 else
2964 snac_log(snac, xs_fmt("repeated '%s' from %s to %s", type, actor, object)); 2976 snac_log(snac, xs_fmt("repeated '%s' from %s to %s", type, actor, object));
@@ -3395,7 +3407,7 @@ void process_user_queue_item(snac *user, xs_dict *q_item)
3395 actor_add(actor, actor_o); 3407 actor_add(actor, actor_o);
3396 } 3408 }
3397 else { 3409 else {
3398 if (status == HTTP_STATUS_GONE) { 3410 if (status == HTTP_STATUS_GONE || status == HTTP_STATUS_NOT_FOUND) {
3399 actor_failure(actor, 1); 3411 actor_failure(actor, 1);
3400 snac_log(user, xs_fmt("actor_refresh marking actor %s as broken %d", actor, status)); 3412 snac_log(user, xs_fmt("actor_refresh marking actor %s as broken %d", actor, status));
3401 } 3413 }