commit 3a97721

default  ·  2023-02-20 12:19:29 +0000 UTC
parent 9d02e70
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.
1 files changed,  +18, -5
+18, -5
 1@@ -1113,14 +1113,27 @@ void process_user_queue_item(snac *snac, xs_dict *q_item)
 2 
 3     if (strcmp(type, "message") == 0) {
 4         xs_dict *msg = xs_dict_get(q_item, "message");
 5-        xs *inboxes  = inbox_list(snac, msg);
 6+        xs *rcpts    = recipient_list(snac, msg, 1);
 7+        xs_set inboxes;
 8         xs_list *p;
 9-        xs_str *inbox;
10+        xs_str *actor;
11 
12-        p = inboxes;
13-        while (xs_list_iter(&p, &inbox)) {
14-            enqueue_output(snac, msg, inbox, 0);
15+        xs_set_init(&inboxes);
16+
17+        p = rcpts;
18+        while (xs_list_iter(&p, &actor)) {
19+            xs *inbox = get_actor_inbox(snac, actor);
20+
21+            if (inbox != NULL) {
22+                /* add to the set and, if it's not there, send message */
23+                if (xs_set_add(&inboxes, inbox) == 1)
24+                    enqueue_output(snac, msg, inbox, 0);
25+            }
26+            else
27+                snac_log(snac, xs_fmt("cannot find inbox for %s", actor));
28         }
29+
30+        xs_set_free(&inboxes);
31     }
32     else
33     if (strcmp(type, "input") == 0) {