From 4d53a7b6f7f45f524313980461f5d2a6ef965949 Mon Sep 17 00:00:00 2001 From: default Date: Sat, 11 May 2024 19:16:54 +0200 Subject: [PATCH] In timeline_request(), call enqueue_actor_request on actor errors. --- activitypub.c | 26 +++++++++++++++----------- data.c | 11 ++++++----- snac.h | 2 +- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/activitypub.c b/activitypub.c index 301fd4c..280ac87 100644 --- a/activitypub.c +++ b/activitypub.c @@ -356,23 +356,27 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level) } if (xs_match(type, "Note|Page|Article|Video")) { - const char *actor = get_atto(object); - if (content_check("filter_reject.txt", object)) snac_log(snac, xs_fmt("timeline_request rejected by content %s", nid)); else { - /* request (and drop) the actor for this entry */ - if (!xs_is_null(actor)) - actor_request(snac, actor, NULL); + const char *actor = get_atto(object); - /* does it have an ancestor? */ - char *in_reply_to = xs_dict_get(object, "inReplyTo"); + if (!xs_is_null(actor)) { + /* request (and drop) the actor for this entry */ + if (!valid_status(actor_request(snac, actor, NULL))) { + /* failed? retry later */ + enqueue_actor_refresh(snac, actor, 60); + } - /* store */ - timeline_add(snac, nid, object); + /* does it have an ancestor? */ + char *in_reply_to = xs_dict_get(object, "inReplyTo"); - /* recurse! */ - timeline_request(snac, &in_reply_to, NULL, level + 1); + /* store */ + timeline_add(snac, nid, object); + + /* recurse! */ + timeline_request(snac, &in_reply_to, NULL, level + 1); + } } } } diff --git a/data.c b/data.c index d037af0..8016ce1 100644 --- a/data.c +++ b/data.c @@ -1632,7 +1632,7 @@ int actor_get_refresh(snac *user, const char *actor, xs_dict **data) int status = actor_get(actor, data); if (status == 205 && user && !xs_startswith(actor, srv_baseurl)) - enqueue_actor_refresh(user, actor); + enqueue_actor_refresh(user, actor, 0); return status; } @@ -2830,13 +2830,14 @@ void enqueue_verify_links(snac *user) } -void enqueue_actor_refresh(snac *user, const char *actor) +void enqueue_actor_refresh(snac *user, const char *actor, int forward_secs) /* enqueues an actor refresh */ { - xs *qmsg = _new_qmsg("actor_refresh", "", 0); - char *ntid = xs_dict_get(qmsg, "ntid"); - xs *fn = xs_fmt("%s/queue/%s.json", user->basedir, ntid); + xs *qmsg = _new_qmsg("actor_refresh", "", 0); + xs *ntid = tid(forward_secs); + xs *fn = xs_fmt("%s/queue/%s.json", user->basedir, ntid); + qmsg = xs_dict_set(qmsg, "ntid", ntid); qmsg = xs_dict_append(qmsg, "actor", actor); qmsg = _enqueue_put(fn, qmsg); diff --git a/snac.h b/snac.h index c4e062b..de2ee1e 100644 --- a/snac.h +++ b/snac.h @@ -232,7 +232,7 @@ void enqueue_message(snac *snac, const xs_dict *msg); void enqueue_close_question(snac *user, const char *id, int end_secs); void enqueue_object_request(snac *user, const char *id, int forward_secs); void enqueue_verify_links(snac *user); -void enqueue_actor_refresh(snac *user, const char *actor); +void enqueue_actor_refresh(snac *user, const char *actor, int forward_secs); void enqueue_request_replies(snac *user, const char *id); int was_question_voted(snac *user, const char *id);