diff options
| author | 2024-05-09 09:09:22 +0200 | |
|---|---|---|
| committer | 2024-05-09 09:09:22 +0200 | |
| commit | 2c8d4ce6bd227377fbfa02d92abdbff8a65150c3 (patch) | |
| tree | 5ca04263e9b2d9639db1585f5aef8744ac3b0630 /mastoapi.c | |
| parent | Merge branch 'master' of grunfink-codeberg:grunfink/snac2 (diff) | |
| download | penes-snac2-2c8d4ce6bd227377fbfa02d92abdbff8a65150c3.tar.gz penes-snac2-2c8d4ce6bd227377fbfa02d92abdbff8a65150c3.tar.xz penes-snac2-2c8d4ce6bd227377fbfa02d92abdbff8a65150c3.zip | |
mastoapi: Added content search.
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 30 |
1 files changed, 26 insertions, 4 deletions
| @@ -2228,8 +2228,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 2228 | /* reply something only for offset 0; otherwise, | 2228 | /* reply something only for offset 0; otherwise, |
| 2229 | apps like Tusky keep asking again and again */ | 2229 | apps like Tusky keep asking again and again */ |
| 2230 | 2230 | ||
| 2231 | if (!xs_is_null(q) && !xs_is_null(type)) { | 2231 | if (!xs_is_null(q)) { |
| 2232 | if (strcmp(type, "accounts") == 0) { | 2232 | if (xs_is_null(type) || strcmp(type, "accounts") == 0) { |
| 2233 | /* do a webfinger query */ | 2233 | /* do a webfinger query */ |
| 2234 | char *actor = NULL; | 2234 | char *actor = NULL; |
| 2235 | char *user = NULL; | 2235 | char *user = NULL; |
| @@ -2244,8 +2244,8 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 2244 | } | 2244 | } |
| 2245 | } | 2245 | } |
| 2246 | } | 2246 | } |
| 2247 | else | 2247 | |
| 2248 | if (strcmp(type, "hashtags") == 0) { | 2248 | if (xs_is_null(type) || strcmp(type, "hashtags") == 0) { |
| 2249 | /* search this tag */ | 2249 | /* search this tag */ |
| 2250 | xs *tl = tag_search((char *)q, 0, 1); | 2250 | xs *tl = tag_search((char *)q, 0, 1); |
| 2251 | 2251 | ||
| @@ -2260,6 +2260,28 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 2260 | htl = xs_list_append(htl, d); | 2260 | htl = xs_list_append(htl, d); |
| 2261 | } | 2261 | } |
| 2262 | } | 2262 | } |
| 2263 | |||
| 2264 | if (xs_is_null(type) || strcmp(type, "statuses") == 0) { | ||
| 2265 | int to = 0; | ||
| 2266 | xs *tl = content_search(&snac1, q, 1, 0, &to); | ||
| 2267 | int c = 0; | ||
| 2268 | char *v; | ||
| 2269 | |||
| 2270 | while (xs_list_next(tl, &v, &c)) { | ||
| 2271 | xs *post = NULL; | ||
| 2272 | |||
| 2273 | if (!valid_status(timeline_get_by_md5(&snac1, v, &post))) | ||
| 2274 | continue; | ||
| 2275 | |||
| 2276 | char *type = xs_dict_get_def(post, "type", "-"); | ||
| 2277 | if (!xs_match(type, "Note|Article|Question|Page|Video")) | ||
| 2278 | continue; | ||
| 2279 | |||
| 2280 | xs *s = mastoapi_status(&snac1, post); | ||
| 2281 | |||
| 2282 | stl = xs_list_append(stl, s); | ||
| 2283 | } | ||
| 2284 | } | ||
| 2263 | } | 2285 | } |
| 2264 | } | 2286 | } |
| 2265 | 2287 | ||