summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--activitypub.c26
-rw-r--r--data.c2
-rw-r--r--snac.h2
3 files changed, 17 insertions, 13 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}
diff --git a/data.c b/data.c
index ded3c42..8b1a92e 100644
--- a/data.c
+++ b/data.c
@@ -2948,7 +2948,7 @@ void enqueue_output_by_actor(snac *snac, const xs_dict *msg,
2948 const xs_str *actor, int retries) 2948 const xs_str *actor, int retries)
2949/* enqueues an output message for an actor */ 2949/* enqueues an output message for an actor */
2950{ 2950{
2951 xs *inbox = get_actor_inbox(actor); 2951 xs *inbox = get_actor_inbox(actor, 1);
2952 2952
2953 if (!xs_is_null(inbox)) 2953 if (!xs_is_null(inbox))
2954 enqueue_output(snac, msg, inbox, retries, 0); 2954 enqueue_output(snac, msg, inbox, retries, 0);
diff --git a/snac.h b/snac.h
index 90413ea..379b81d 100644
--- a/snac.h
+++ b/snac.h
@@ -322,7 +322,7 @@ int send_to_inbox_raw(const char *keyid, const char *seckey,
322 xs_val **payload, int *p_size, int timeout); 322 xs_val **payload, int *p_size, int timeout);
323int send_to_inbox(snac *snac, const xs_str *inbox, const xs_dict *msg, 323int send_to_inbox(snac *snac, const xs_str *inbox, const xs_dict *msg,
324 xs_val **payload, int *p_size, int timeout); 324 xs_val **payload, int *p_size, int timeout);
325xs_str *get_actor_inbox(const char *actor); 325xs_str *get_actor_inbox(const char *actor, int shared);
326int send_to_actor(snac *snac, const char *actor, const xs_dict *msg, 326int send_to_actor(snac *snac, const char *actor, const xs_dict *msg,
327 xs_val **payload, int *p_size, int timeout); 327 xs_val **payload, int *p_size, int timeout);
328int is_msg_public(const xs_dict *msg); 328int is_msg_public(const xs_dict *msg);