commit 3879649
default
·
2024-10-08 15:37:15 +0000 UTC
parent 26a808c
More migration work.
3 files changed,
+17,
-13
+15,
-11
1@@ -419,7 +419,7 @@ int send_to_inbox(snac *snac, const xs_str *inbox, const xs_dict *msg,
2 }
3
4
5-xs_str *get_actor_inbox(const char *actor)
6+xs_str *get_actor_inbox(const char *actor, int shared)
7 /* gets an actor's inbox */
8 {
9 xs *data = NULL;
10@@ -427,7 +427,7 @@ xs_str *get_actor_inbox(const char *actor)
11
12 if (valid_status(actor_request(NULL, actor, &data))) {
13 /* try first endpoints/sharedInbox */
14- if ((v = xs_dict_get(data, "endpoints")))
15+ if (shared && (v = xs_dict_get(data, "endpoints")))
16 v = xs_dict_get(v, "sharedInbox");
17
18 /* try then the regular inbox */
19@@ -444,7 +444,7 @@ int send_to_actor(snac *snac, const char *actor, const xs_dict *msg,
20 /* sends a message to an actor */
21 {
22 int status = HTTP_STATUS_BAD_REQUEST;
23- xs *inbox = get_actor_inbox(actor);
24+ xs *inbox = get_actor_inbox(actor, 1);
25
26 if (!xs_is_null(inbox))
27 status = send_to_inbox(snac, inbox, msg, payload, p_size, timeout);
28@@ -2290,7 +2290,7 @@ void process_user_queue_item(snac *snac, xs_dict *q_item)
29 /* iterate the recipients */
30 c = 0;
31 while (xs_list_next(rcpts, &actor, &c)) {
32- xs *inbox = get_actor_inbox(actor);
33+ xs *inbox = get_actor_inbox(actor, 1);
34
35 if (inbox != NULL) {
36 /* add to the set and, if it's not there, send message */
37@@ -2699,14 +2699,18 @@ int migrate_account(snac *user)
38 xs *move = msg_move(user, new_account);
39 xs *fwers = follower_list(user);
40
41-/*
42- xs_json_dump(move, 4, stdout);
43- printf("\n");
44- xs_json_dump(fwers, 4, stdout);
45- printf("\n");
46-*/
47+ snac_log(user, xs_fmt("WORK IN PROGRESS - ANYTHING CAN HAPPEN"));
48
49- printf("WORK IN PROGRESS - NOT YET USABLE (BUT HARMLESS)\n");
50+ const char *actor;
51+ xs_list_foreach(fwers, actor) {
52+ /* get the actor inbox, excluding the shared one */
53+ xs *inbox = get_actor_inbox(actor, 0);
54+
55+ if (xs_is_null(inbox))
56+ snac_log(user, xs_fmt("migrate_account: cannot get inbox for actor %s", actor));
57+ else
58+ enqueue_output(user, move, inbox, 0, 0);
59+ }
60
61 return 0;
62 }
M
data.c
+1,
-1
1@@ -2948,7 +2948,7 @@ void enqueue_output_by_actor(snac *snac, const xs_dict *msg,
2 const xs_str *actor, int retries)
3 /* enqueues an output message for an actor */
4 {
5- xs *inbox = get_actor_inbox(actor);
6+ xs *inbox = get_actor_inbox(actor, 1);
7
8 if (!xs_is_null(inbox))
9 enqueue_output(snac, msg, inbox, retries, 0);
M
snac.h
+1,
-1
1@@ -322,7 +322,7 @@ int send_to_inbox_raw(const char *keyid, const char *seckey,
2 xs_val **payload, int *p_size, int timeout);
3 int send_to_inbox(snac *snac, const xs_str *inbox, const xs_dict *msg,
4 xs_val **payload, int *p_size, int timeout);
5-xs_str *get_actor_inbox(const char *actor);
6+xs_str *get_actor_inbox(const char *actor, int shared);
7 int send_to_actor(snac *snac, const char *actor, const xs_dict *msg,
8 xs_val **payload, int *p_size, int timeout);
9 int is_msg_public(const xs_dict *msg);