diff options
| author | 2023-05-15 11:23:36 +0200 | |
|---|---|---|
| committer | 2023-05-15 11:23:36 +0200 | |
| commit | bd8886f8a6f17f588628b01476f15309167b0d30 (patch) | |
| tree | e6a2ba66d03c23c2cce225d10f5d2c18ad3ab214 | |
| parent | Bumped version. (diff) | |
| download | snac2-bd8886f8a6f17f588628b01476f15309167b0d30.tar.gz snac2-bd8886f8a6f17f588628b01476f15309167b0d30.tar.xz snac2-bd8886f8a6f17f588628b01476f15309167b0d30.zip | |
Don't repeat accounts when searching.
| -rw-r--r-- | mastoapi.c | 10 |
1 files changed, 10 insertions, 0 deletions
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "xs_io.h" | 10 | #include "xs_io.h" |
| 11 | #include "xs_time.h" | 11 | #include "xs_time.h" |
| 12 | #include "xs_glob.h" | 12 | #include "xs_glob.h" |
| 13 | #include "xs_set.h" | ||
| 13 | 14 | ||
| 14 | #include "snac.h" | 15 | #include "snac.h" |
| 15 | 16 | ||
| @@ -966,6 +967,9 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 966 | xs *wing = following_list(&snac1); | 967 | xs *wing = following_list(&snac1); |
| 967 | xs *wers = follower_list(&snac1); | 968 | xs *wers = follower_list(&snac1); |
| 968 | xs_list *p; | 969 | xs_list *p; |
| 970 | xs_set seen; | ||
| 971 | |||
| 972 | xs_set_init(&seen); | ||
| 969 | 973 | ||
| 970 | xs_list *lsts[] = { wing, wers, NULL }; | 974 | xs_list *lsts[] = { wing, wers, NULL }; |
| 971 | int n; | 975 | int n; |
| @@ -973,6 +977,10 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 973 | xs_str *v; | 977 | xs_str *v; |
| 974 | 978 | ||
| 975 | while (xs_list_iter(&p, &v)) { | 979 | while (xs_list_iter(&p, &v)) { |
| 980 | /* already seen? skip */ | ||
| 981 | if (xs_set_add(&seen, v) == 0) | ||
| 982 | continue; | ||
| 983 | |||
| 976 | xs *actor = NULL; | 984 | xs *actor = NULL; |
| 977 | 985 | ||
| 978 | if (valid_status(object_get(v, &actor))) { | 986 | if (valid_status(object_get(v, &actor))) { |
| @@ -986,6 +994,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 986 | } | 994 | } |
| 987 | } | 995 | } |
| 988 | } | 996 | } |
| 997 | |||
| 998 | xs_set_free(&seen); | ||
| 989 | } | 999 | } |
| 990 | } | 1000 | } |
| 991 | else | 1001 | else |