commit 3a97721c30e1b8d0a8f8d47ef60b64ec6eb06e5e
parent 9d02e70a2fd05b48abde342ea76e82ad7a30f3f1
Author: default <nobody@localhost>
Date: Mon, 20 Feb 2023 13:19:29 +0100
Unrolled the recipient-to-inbox process in process_user_queue_item().
Instead of calling inbox_list(), waiting for it to end and then
sending to all the "uniqueized" inboxes, the sending is done everytime
a unique inbox is found.
Diffstat:
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/activitypub.c b/activitypub.c
@@ -1113,14 +1113,27 @@ void process_user_queue_item(snac *snac, xs_dict *q_item)
if (strcmp(type, "message") == 0) {
xs_dict *msg = xs_dict_get(q_item, "message");
- xs *inboxes = inbox_list(snac, msg);
+ xs *rcpts = recipient_list(snac, msg, 1);
+ xs_set inboxes;
xs_list *p;
- xs_str *inbox;
+ xs_str *actor;
- p = inboxes;
- while (xs_list_iter(&p, &inbox)) {
- enqueue_output(snac, msg, inbox, 0);
+ xs_set_init(&inboxes);
+
+ p = rcpts;
+ while (xs_list_iter(&p, &actor)) {
+ xs *inbox = get_actor_inbox(snac, actor);
+
+ if (inbox != NULL) {
+ /* add to the set and, if it's not there, send message */
+ if (xs_set_add(&inboxes, inbox) == 1)
+ enqueue_output(snac, msg, inbox, 0);
+ }
+ else
+ snac_log(snac, xs_fmt("cannot find inbox for %s", actor));
}
+
+ xs_set_free(&inboxes);
}
else
if (strcmp(type, "input") == 0) {