diff options
| -rw-r--r-- | activitypub.c | 11 | ||||
| -rw-r--r-- | data.c | 17 | ||||
| -rw-r--r-- | snac.h | 1 |
3 files changed, 29 insertions, 0 deletions
diff --git a/activitypub.c b/activitypub.c index 9a63de7..79ec98b 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -990,6 +990,17 @@ void process_queue(snac *snac) | |||
| 990 | if ((type = xs_dict_get(q_item, "type")) == NULL) | 990 | if ((type = xs_dict_get(q_item, "type")) == NULL) |
| 991 | type = "output"; | 991 | type = "output"; |
| 992 | 992 | ||
| 993 | if (strcmp(type, "message") == 0) { | ||
| 994 | char *msg = xs_dict_get(q_item, "message"); | ||
| 995 | xs *inboxes = inbox_list(snac, msg); | ||
| 996 | char *p, *v; | ||
| 997 | |||
| 998 | p = inboxes; | ||
| 999 | while (xs_list_iter(&p, &v)) { | ||
| 1000 | enqueue_output(snac, msg, v, 0); | ||
| 1001 | } | ||
| 1002 | } | ||
| 1003 | else | ||
| 993 | if (strcmp(type, "output") == 0) { | 1004 | if (strcmp(type, "output") == 0) { |
| 994 | int status; | 1005 | int status; |
| 995 | char *inbox = xs_dict_get(q_item, "inbox"); | 1006 | char *inbox = xs_dict_get(q_item, "inbox"); |
| @@ -1384,6 +1384,23 @@ void enqueue_email(snac *snac, char *msg, int retries) | |||
| 1384 | } | 1384 | } |
| 1385 | 1385 | ||
| 1386 | 1386 | ||
| 1387 | void enqueue_message(snac *snac, char *msg) | ||
| 1388 | /* enqueues an output message */ | ||
| 1389 | { | ||
| 1390 | char *id = xs_dict_get(msg, "id"); | ||
| 1391 | xs *ntid = tid(0); | ||
| 1392 | xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid); | ||
| 1393 | xs *qmsg = xs_dict_new(); | ||
| 1394 | |||
| 1395 | qmsg = xs_dict_append(qmsg, "type", "message"); | ||
| 1396 | qmsg = xs_dict_append(qmsg, "message", msg); | ||
| 1397 | |||
| 1398 | _enqueue_put(fn, qmsg); | ||
| 1399 | |||
| 1400 | snac_debug(snac, 1, xs_fmt("enqueue_message %s", id)); | ||
| 1401 | } | ||
| 1402 | |||
| 1403 | |||
| 1387 | d_char *queue(snac *snac) | 1404 | d_char *queue(snac *snac) |
| 1388 | /* returns a list with filenames that can be dequeued */ | 1405 | /* returns a list with filenames that can be dequeued */ |
| 1389 | { | 1406 | { |
| @@ -127,6 +127,7 @@ void enqueue_input(snac *snac, char *msg, char *req, int retries); | |||
| 127 | void enqueue_output(snac *snac, char *msg, char *inbox, int retries); | 127 | void enqueue_output(snac *snac, char *msg, char *inbox, int retries); |
| 128 | void enqueue_output_by_actor(snac *snac, char *msg, char *actor, int retries); | 128 | void enqueue_output_by_actor(snac *snac, char *msg, char *actor, int retries); |
| 129 | void enqueue_email(snac *snac, char *msg, int retries); | 129 | void enqueue_email(snac *snac, char *msg, int retries); |
| 130 | void enqueue_message(snac *snac, char *msg); | ||
| 130 | 131 | ||
| 131 | d_char *queue(snac *snac); | 132 | d_char *queue(snac *snac); |
| 132 | d_char *dequeue(snac *snac, char *fn); | 133 | d_char *dequeue(snac *snac, char *fn); |