summaryrefslogtreecommitdiff
path: root/mastoapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'mastoapi.c')
-rw-r--r--mastoapi.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/mastoapi.c b/mastoapi.c
index 3f8b59d..09e18a1 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -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) {