summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2022-09-26 09:22:05 +0200
committerGravatar default2022-09-26 09:22:05 +0200
commit46ee4a4a188c8aabab7c1bd97581a3b7820955ad (patch)
treeb0e02beab6fdc0e1c0315cd17af1099feb73e898
parentLink to local if the child id is from this actor. (diff)
downloadsnac2-46ee4a4a188c8aabab7c1bd97581a3b7820955ad.tar.gz
snac2-46ee4a4a188c8aabab7c1bd97581a3b7820955ad.tar.xz
snac2-46ee4a4a188c8aabab7c1bd97581a3b7820955ad.zip
New function recipients().
-rw-r--r--activitypub.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/activitypub.c b/activitypub.c
index 9fa5ba8..a78aacf 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -379,6 +379,43 @@ void process_queue(snac *snac)
379} 379}
380 380
381 381
382d_char *recipents(snac *snac, char *msg, int expand_public)
383/* returns the list of recipients for a message */
384{
385 d_char *list = xs_list_new();
386 char *to = xs_dict_get(msg, "to");
387 char *cc = xs_dict_get(msg, "cc");
388 int n;
389
390 char *lists[] = { to, cc, NULL };
391 for (n = 0; lists[n]; n++) {
392 char *l = lists[n];
393 char *v;
394
395 while (xs_list_iter(&l, &v)) {
396 if (expand_public && strcmp(v, public_address) == 0) {
397 /* iterate the followers and add them */
398 xs *fwers = follower_list(snac);
399 char *fw;
400
401 char *p = fwers;
402 while (xs_list_iter(&p, &fw)) {
403 if (!xs_list_in(list, fw))
404 list = xs_list_append(list, fw);
405 }
406 }
407 else
408 if (!xs_list_in(list, v))
409 list = xs_list_append(list, v);
410 }
411 }
412
413 return list;
414}
415
416
417/** HTTP handlers */
418
382int activitypub_get_handler(d_char *req, char *q_path, 419int activitypub_get_handler(d_char *req, char *q_path,
383 char **body, int *b_size, char **ctype) 420 char **body, int *b_size, char **ctype)
384{ 421{