diff options
| author | 2024-12-22 09:26:17 +0100 | |
|---|---|---|
| committer | 2024-12-22 09:26:17 +0100 | |
| commit | 0bbecf53a670202334128b1372cfc5d83273fbf1 (patch) | |
| tree | 1d3ff2bc387c9f5eaf9db84225b87deef850b4ca /mastoapi.c | |
| parent | Account names can also contain periods (in account search). (diff) | |
| download | penes-snac2-0bbecf53a670202334128b1372cfc5d83273fbf1.tar.gz penes-snac2-0bbecf53a670202334128b1372cfc5d83273fbf1.tar.xz penes-snac2-0bbecf53a670202334128b1372cfc5d83273fbf1.zip | |
mastoapi: allow search for post URLs.
Diffstat (limited to 'mastoapi.c')
| -rw-r--r-- | mastoapi.c | 31 |
1 files changed, 31 insertions, 0 deletions
| @@ -2377,6 +2377,37 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path, | |||
| 2377 | if (xs_is_null(offset) || strcmp(offset, "0") == 0) { | 2377 | if (xs_is_null(offset) || strcmp(offset, "0") == 0) { |
| 2378 | /* reply something only for offset 0; otherwise, | 2378 | /* reply something only for offset 0; otherwise, |
| 2379 | apps like Tusky keep asking again and again */ | 2379 | apps like Tusky keep asking again and again */ |
| 2380 | if (xs_startswith(q, "https://")) { | ||
| 2381 | xs *md5 = xs_md5_hex(q, strlen(q)); | ||
| 2382 | |||
| 2383 | if (!timeline_here(&snac1, md5)) { | ||
| 2384 | xs *object = NULL; | ||
| 2385 | int status; | ||
| 2386 | |||
| 2387 | status = activitypub_request(&snac1, q, &object); | ||
| 2388 | snac_debug(&snac1, 1, xs_fmt("Request searched URL %s %d", q, status)); | ||
| 2389 | |||
| 2390 | if (valid_status(status)) { | ||
| 2391 | /* got it; also request the actor */ | ||
| 2392 | const char *attr_to = get_atto(object); | ||
| 2393 | xs *actor_obj = NULL; | ||
| 2394 | |||
| 2395 | if (!xs_is_null(attr_to)) { | ||
| 2396 | status = actor_request(&snac1, attr_to, &actor_obj); | ||
| 2397 | |||
| 2398 | snac_debug(&snac1, 1, xs_fmt("Request author %s of %s %d", attr_to, q, status)); | ||
| 2399 | |||
| 2400 | if (valid_status(status)) { | ||
| 2401 | /* add the actor */ | ||
| 2402 | actor_add(attr_to, actor_obj); | ||
| 2403 | |||
| 2404 | /* add the post to the timeline */ | ||
| 2405 | timeline_add(&snac1, q, object); | ||
| 2406 | } | ||
| 2407 | } | ||
| 2408 | } | ||
| 2409 | } | ||
| 2410 | } | ||
| 2380 | 2411 | ||
| 2381 | if (!xs_is_null(q)) { | 2412 | if (!xs_is_null(q)) { |
| 2382 | if (xs_is_null(type) || strcmp(type, "accounts") == 0) { | 2413 | if (xs_is_null(type) || strcmp(type, "accounts") == 0) { |