mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-10 03:50:38 +03:00
mastoapi: Added content search.
This commit is contained in:
parent
06599de966
commit
2c8d4ce6bd
30
mastoapi.c
30
mastoapi.c
@ -2228,8 +2228,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
|||||||
/* reply something only for offset 0; otherwise,
|
/* reply something only for offset 0; otherwise,
|
||||||
apps like Tusky keep asking again and again */
|
apps like Tusky keep asking again and again */
|
||||||
|
|
||||||
if (!xs_is_null(q) && !xs_is_null(type)) {
|
if (!xs_is_null(q)) {
|
||||||
if (strcmp(type, "accounts") == 0) {
|
if (xs_is_null(type) || strcmp(type, "accounts") == 0) {
|
||||||
/* do a webfinger query */
|
/* do a webfinger query */
|
||||||
char *actor = NULL;
|
char *actor = NULL;
|
||||||
char *user = NULL;
|
char *user = NULL;
|
||||||
@ -2244,8 +2244,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
if (strcmp(type, "hashtags") == 0) {
|
if (xs_is_null(type) || strcmp(type, "hashtags") == 0) {
|
||||||
/* search this tag */
|
/* search this tag */
|
||||||
xs *tl = tag_search((char *)q, 0, 1);
|
xs *tl = tag_search((char *)q, 0, 1);
|
||||||
|
|
||||||
@ -2260,6 +2260,28 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
|||||||
htl = xs_list_append(htl, d);
|
htl = xs_list_append(htl, d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xs_is_null(type) || strcmp(type, "statuses") == 0) {
|
||||||
|
int to = 0;
|
||||||
|
xs *tl = content_search(&snac1, q, 1, 0, &to);
|
||||||
|
int c = 0;
|
||||||
|
char *v;
|
||||||
|
|
||||||
|
while (xs_list_next(tl, &v, &c)) {
|
||||||
|
xs *post = NULL;
|
||||||
|
|
||||||
|
if (!valid_status(timeline_get_by_md5(&snac1, v, &post)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
char *type = xs_dict_get_def(post, "type", "-");
|
||||||
|
if (!xs_match(type, "Note|Article|Question|Page|Video"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
xs *s = mastoapi_status(&snac1, post);
|
||||||
|
|
||||||
|
stl = xs_list_append(stl, s);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user