commit bd8886f8a6f17f588628b01476f15309167b0d30
parent d3c1b3127ae264811e3ca6b850fbc32a984e039e
Author: default <nobody@localhost>
Date: Mon, 15 May 2023 11:23:36 +0200
Don't repeat accounts when searching.
Diffstat:
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git 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