diff options
author | default <nobody@localhost> | 2022-09-26 09:22:05 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2022-09-26 09:22:05 +0200 |
commit | 46ee4a4a188c8aabab7c1bd97581a3b7820955ad (patch) | |
tree | b0e02beab6fdc0e1c0315cd17af1099feb73e898 | |
parent | 74aef6994a9ae6655706ac65514e117cf8073f72 (diff) |
New function recipients().
-rw-r--r-- | activitypub.c | 37 |
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) } +d_char *recipents(snac *snac, char *msg, int expand_public) +/* returns the list of recipients for a message */ +{ + d_char *list = xs_list_new(); + char *to = xs_dict_get(msg, "to"); + char *cc = xs_dict_get(msg, "cc"); + int n; + + char *lists[] = { to, cc, NULL }; + for (n = 0; lists[n]; n++) { + char *l = lists[n]; + char *v; + + while (xs_list_iter(&l, &v)) { + if (expand_public && strcmp(v, public_address) == 0) { + /* iterate the followers and add them */ + xs *fwers = follower_list(snac); + char *fw; + + char *p = fwers; + while (xs_list_iter(&p, &fw)) { + if (!xs_list_in(list, fw)) + list = xs_list_append(list, fw); + } + } + else + if (!xs_list_in(list, v)) + list = xs_list_append(list, v); + } + } + + return list; +} + + +/** HTTP handlers */ + int activitypub_get_handler(d_char *req, char *q_path, char **body, int *b_size, char **ctype) { |