mastoapi: added search by tag.

This commit is contained in:
default 2024-03-02 05:56:02 +01:00
parent 5431f6aacd
commit 127f40905e

View file

@ -2031,7 +2031,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
/* reply something only for offset 0; otherwise,
apps like Tusky keep asking again and again */
if (!xs_is_null(q) && !xs_is_null(type) && strcmp(type, "accounts") == 0) {
if (!xs_is_null(q) && !xs_is_null(type)) {
if (strcmp(type, "accounts") == 0) {
/* do a webfinger query */
char *actor = NULL;
char *user = NULL;
@ -2046,6 +2047,23 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
}
}
}
else
if (strcmp(type, "hashtags") == 0) {
/* search this tag */
xs *tl = tag_search((char *)q, 0, 1);
if (xs_list_len(tl)) {
xs *d = xs_dict_new();
d = xs_dict_append(d, "name", q);
xs *url = xs_fmt("%s?t=%s", srv_baseurl, q);
d = xs_dict_append(d, "url", url);
d = xs_dict_append(d, "history", xs_stock_list);
htl = xs_list_append(htl, d);
}
}
}
}
res = xs_dict_append(res, "accounts", acl);