summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/activitypub.c b/activitypub.c
index babca3d..19e39a9 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -419,7 +419,7 @@ int send_to_inbox(snac *snac, const xs_str *inbox, const xs_dict *msg,
419} 419}
420 420
421 421
422xs_str *get_actor_inbox(const char *actor) 422xs_str *get_actor_inbox(const char *actor, int shared)
423/* gets an actor's inbox */ 423/* gets an actor's inbox */
424{ 424{
425 xs *data = NULL; 425 xs *data = NULL;
@@ -427,7 +427,7 @@ xs_str *get_actor_inbox(const char *actor)
427 427
428 if (valid_status(actor_request(NULL, actor, &data))) { 428 if (valid_status(actor_request(NULL, actor, &data))) {
429 /* try first endpoints/sharedInbox */ 429 /* try first endpoints/sharedInbox */
430 if ((v = xs_dict_get(data, "endpoints"))) 430 if (shared && (v = xs_dict_get(data, "endpoints")))
431 v = xs_dict_get(v, "sharedInbox"); 431 v = xs_dict_get(v, "sharedInbox");
432 432
433 /* try then the regular inbox */ 433 /* try then the regular inbox */
@@ -444,7 +444,7 @@ int send_to_actor(snac *snac, const char *actor, const xs_dict *msg,
444/* sends a message to an actor */ 444/* sends a message to an actor */
445{ 445{
446 int status = HTTP_STATUS_BAD_REQUEST; 446 int status = HTTP_STATUS_BAD_REQUEST;
447 xs *inbox = get_actor_inbox(actor); 447 xs *inbox = get_actor_inbox(actor, 1);
448 448
449 if (!xs_is_null(inbox)) 449 if (!xs_is_null(inbox))
450 status = send_to_inbox(snac, inbox, msg, payload, p_size, timeout); 450 status = send_to_inbox(snac, inbox, msg, payload, p_size, timeout);
@@ -2290,7 +2290,7 @@ void process_user_queue_item(snac *snac, xs_dict *q_item)
2290 /* iterate the recipients */ 2290 /* iterate the recipients */
2291 c = 0; 2291 c = 0;
2292 while (xs_list_next(rcpts, &actor, &c)) { 2292 while (xs_list_next(rcpts, &actor, &c)) {
2293 xs *inbox = get_actor_inbox(actor); 2293 xs *inbox = get_actor_inbox(actor, 1);
2294 2294
2295 if (inbox != NULL) { 2295 if (inbox != NULL) {
2296 /* add to the set and, if it's not there, send message */ 2296 /* add to the set and, if it's not there, send message */
@@ -2699,14 +2699,18 @@ int migrate_account(snac *user)
2699 xs *move = msg_move(user, new_account); 2699 xs *move = msg_move(user, new_account);
2700 xs *fwers = follower_list(user); 2700 xs *fwers = follower_list(user);
2701 2701
2702/* 2702 snac_log(user, xs_fmt("WORK IN PROGRESS - ANYTHING CAN HAPPEN"));
2703 xs_json_dump(move, 4, stdout);
2704 printf("\n");
2705 xs_json_dump(fwers, 4, stdout);
2706 printf("\n");
2707*/
2708 2703
2709 printf("WORK IN PROGRESS - NOT YET USABLE (BUT HARMLESS)\n"); 2704 const char *actor;
2705 xs_list_foreach(fwers, actor) {
2706 /* get the actor inbox, excluding the shared one */
2707 xs *inbox = get_actor_inbox(actor, 0);
2708
2709 if (xs_is_null(inbox))
2710 snac_log(user, xs_fmt("migrate_account: cannot get inbox for actor %s", actor));
2711 else
2712 enqueue_output(user, move, inbox, 0, 0);
2713 }
2710 2714
2711 return 0; 2715 return 0;
2712} 2716}