mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 14:35:04 +00:00
Also find local users in /api/v1/search.
This commit is contained in:
parent
32b53e8db5
commit
e6eb1adc65
3 changed files with 29 additions and 3 deletions
2
data.c
2
data.c
|
@ -224,7 +224,7 @@ int user_open(snac *snac, const char *uid)
|
|||
}
|
||||
|
||||
|
||||
d_char *user_list(void)
|
||||
xs_list *user_list(void)
|
||||
/* returns the list of user ids */
|
||||
{
|
||||
xs *spec = xs_fmt("%s/user/" "*", srv_basedir);
|
||||
|
|
28
mastoapi.c
28
mastoapi.c
|
@ -974,15 +974,41 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
|||
out = xs_list_new();
|
||||
xs *wing = following_list(&snac1);
|
||||
xs *wers = follower_list(&snac1);
|
||||
xs *ulst = user_list();
|
||||
xs_list *p;
|
||||
xs_str *v;
|
||||
xs_set seen;
|
||||
|
||||
xs_set_init(&seen);
|
||||
|
||||
/* local users */
|
||||
p = ulst;
|
||||
while (xs_list_iter(&p, &v)) {
|
||||
snac user;
|
||||
|
||||
if (strcmp(v, xs_dict_get(snac1.config, "uid")) == 0)
|
||||
continue;
|
||||
|
||||
if (user_open(&user, v)) {
|
||||
xs *v2 = xs_tolower_i(xs_dup(v));
|
||||
|
||||
if (xs_startswith(v2, q)) {
|
||||
xs *actor = msg_actor(&user);
|
||||
xs *acct = mastoapi_account(actor);
|
||||
|
||||
out = xs_list_append(out, acct);
|
||||
}
|
||||
|
||||
xs_set_add(&seen, user.actor);
|
||||
|
||||
user_free(&user);
|
||||
}
|
||||
}
|
||||
|
||||
/* user relations */
|
||||
xs_list *lsts[] = { wing, wers, NULL };
|
||||
int n;
|
||||
for (n = 0; (p = lsts[n]) != NULL; n++) {
|
||||
xs_str *v;
|
||||
|
||||
while (xs_list_iter(&p, &v)) {
|
||||
/* already seen? skip */
|
||||
|
|
2
snac.h
2
snac.h
|
@ -43,7 +43,7 @@ typedef struct _snac {
|
|||
|
||||
int user_open(snac *snac, const char *uid);
|
||||
void user_free(snac *snac);
|
||||
d_char *user_list(void);
|
||||
xs_list *user_list(void);
|
||||
int user_open_by_md5(snac *snac, const char *md5);
|
||||
|
||||
void snac_debug(snac *snac, int level, d_char *str);
|
||||
|
|
Loading…
Reference in a new issue