summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--activitypub.c27
-rw-r--r--xs_set.h1
-rw-r--r--xs_version.h2
3 files changed, 16 insertions, 14 deletions
diff --git a/activitypub.c b/activitypub.c
index d22261d..1e4130c 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -9,6 +9,7 @@
9#include "xs_openssl.h" 9#include "xs_openssl.h"
10#include "xs_regex.h" 10#include "xs_regex.h"
11#include "xs_time.h" 11#include "xs_time.h"
12#include "xs_set.h"
12 13
13#include "snac.h" 14#include "snac.h"
14 15
@@ -169,11 +170,13 @@ int send_to_actor(snac *snac, char *actor, char *msg, d_char **payload, int *p_s
169d_char *recipient_list(snac *snac, char *msg, int expand_public) 170d_char *recipient_list(snac *snac, char *msg, int expand_public)
170/* returns the list of recipients for a message */ 171/* returns the list of recipients for a message */
171{ 172{
172 d_char *list = xs_list_new();
173 char *to = xs_dict_get(msg, "to"); 173 char *to = xs_dict_get(msg, "to");
174 char *cc = xs_dict_get(msg, "cc"); 174 char *cc = xs_dict_get(msg, "cc");
175 xs_set rcpts;
175 int n; 176 int n;
176 177
178 xs_set_init(&rcpts);
179
177 char *lists[] = { to, cc, NULL }; 180 char *lists[] = { to, cc, NULL };
178 for (n = 0; lists[n]; n++) { 181 for (n = 0; lists[n]; n++) {
179 char *l = lists[n]; 182 char *l = lists[n];
@@ -195,40 +198,38 @@ d_char *recipient_list(snac *snac, char *msg, int expand_public)
195 char *actor; 198 char *actor;
196 199
197 char *p = fwers; 200 char *p = fwers;
198 while (xs_list_iter(&p, &actor)) { 201 while (xs_list_iter(&p, &actor))
199 if (xs_list_in(list, actor) == -1) 202 xs_set_add(&rcpts, actor);
200 list = xs_list_append(list, actor);
201 }
202 } 203 }
203 else 204 else
204 if (xs_list_in(list, v) == -1) 205 xs_set_add(&rcpts, v);
205 list = xs_list_append(list, v);
206 } 206 }
207 } 207 }
208 208
209 return list; 209 return xs_set_result(&rcpts);
210} 210}
211 211
212 212
213d_char *inbox_list(snac *snac, char *msg) 213d_char *inbox_list(snac *snac, char *msg)
214/* returns the list of inboxes that are recipients of this message */ 214/* returns the list of inboxes that are recipients of this message */
215{ 215{
216 d_char *list = xs_list_new(); 216 xs *rcpts = recipient_list(snac, msg, 1);
217 xs *rcpts = recipient_list(snac, msg, 1); 217 xs_set inboxes;
218 char *p, *v; 218 char *p, *v;
219 219
220 xs_set_init(&inboxes);
221
220 p = rcpts; 222 p = rcpts;
221 while (xs_list_iter(&p, &v)) { 223 while (xs_list_iter(&p, &v)) {
222 xs *inbox; 224 xs *inbox;
223 225
224 if ((inbox = get_actor_inbox(snac, v)) != NULL) { 226 if ((inbox = get_actor_inbox(snac, v)) != NULL) {
225 /* add the inbox if it's not already there */ 227 /* add the inbox if it's not already there */
226 if (xs_list_in(list, inbox) == -1) 228 xs_set_add(&inboxes, inbox);
227 list = xs_list_append(list, inbox);
228 } 229 }
229 } 230 }
230 231
231 return list; 232 return xs_set_result(&inboxes);
232} 233}
233 234
234 235
diff --git a/xs_set.h b/xs_set.h
index 5e26abb..f97eb20 100644
--- a/xs_set.h
+++ b/xs_set.h
@@ -12,6 +12,7 @@ typedef struct _xs_set {
12} xs_set; 12} xs_set;
13 13
14void xs_set_init(xs_set *s); 14void xs_set_init(xs_set *s);
15d_char *xs_set_result(xs_set *s);
15void xs_set_free(xs_set *s); 16void xs_set_free(xs_set *s);
16int xs_set_add(xs_set *s, const char *data); 17int xs_set_add(xs_set *s, const char *data);
17 18
diff --git a/xs_version.h b/xs_version.h
index 50dd00a..baefcba 100644
--- a/xs_version.h
+++ b/xs_version.h
@@ -1 +1 @@
/* e9effd101e5ad45cc4209759ae25e4a6de9259e8 */ /* c18371e1f1d3de0f872354f93024a736caebea4d */