From f332acc70d9a335d572a0eb7ffcf34c83362741c Mon Sep 17 00:00:00 2001 From: default Date: Tue, 12 Mar 2024 19:44:08 +0100 Subject: [PATCH] More actor refreshing tweaks. --- activitypub.c | 16 ++++++++++------ data.c | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/activitypub.c b/activitypub.c index bd72cb4..18e270a 100644 --- a/activitypub.c +++ b/activitypub.c @@ -127,8 +127,14 @@ int actor_request(snac *user, const char *actor, xs_dict **data) /* get from disk first */ status = actor_get(actor, data); - if (status != 200) { - /* actor data non-existent or stale: get from the net */ + if (status == 205) { + /* stale actor: use it, but request a refresh */ + if (!xs_startswith(actor, srv_baseurl)) + enqueue_actor_request(user, actor); + } + else + if (!valid_status(status)) { + /* actor data non-existent: get from the net */ status = activitypub_request(user, actor, &payload); if (valid_status(status)) { @@ -149,8 +155,6 @@ int actor_request(snac *user, const char *actor, xs_dict **data) if (valid_status(status) && data && *data) inbox_add_by_actor(*data); } - else - srv_debug(2, xs_fmt("NOT collected")); return status; } @@ -2248,9 +2252,9 @@ void process_user_queue_item(snac *snac, xs_dict *q_item) if (strcmp(type, "actor_request") == 0) { const char *actor = xs_dict_get(q_item, "actor"); double mtime = object_mtime(actor); - double max_time = 3600.0 * 36.0; - if (mtime + max_time < (double) time(NULL)) { + /* only refresh if it was refreshed more than an hour ago */ + if (mtime + 3600.0 < (double) time(NULL)) { xs *actor_o = NULL; int status; diff --git a/data.c b/data.c index 3da25f1..dc5d323 100644 --- a/data.c +++ b/data.c @@ -1596,7 +1596,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(user->actor, srv_baseurl)) + if (status == 205 && user && !xs_startswith(actor, srv_baseurl)) enqueue_actor_request(user, actor); return status;