summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-05-15 11:23:36 +0200
committerdefault <nobody@localhost>2023-05-15 11:23:36 +0200
commitbd8886f8a6f17f588628b01476f15309167b0d30 (patch)
treee6a2ba66d03c23c2cce225d10f5d2c18ad3ab214 /mastoapi.c
parentd3c1b3127ae264811e3ca6b850fbc32a984e039e (diff)
Don't repeat accounts when searching.
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 062fb7e..93c4d5a 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -10,6 +10,7 @@
#include "xs_io.h"
#include "xs_time.h"
#include "xs_glob.h"
+#include "xs_set.h"
#include "snac.h"
@@ -966,6 +967,9 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
xs *wing = following_list(&snac1);
xs *wers = follower_list(&snac1);
xs_list *p;
+ xs_set seen;
+
+ xs_set_init(&seen);
xs_list *lsts[] = { wing, wers, NULL };
int n;
@@ -973,6 +977,10 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
xs_str *v;
while (xs_list_iter(&p, &v)) {
+ /* already seen? skip */
+ if (xs_set_add(&seen, v) == 0)
+ continue;
+
xs *actor = NULL;
if (valid_status(object_get(v, &actor))) {
@@ -986,6 +994,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
}
}
}
+
+ xs_set_free(&seen);
}
}
else