diff options
| author | default <nobody@localhost> | 2026-08-26 07:59:23 +0200 |
|---|---|---|
| committer | default <nobody@localhost> | 2026-08-26 07:59:23 +0200 |
| commit | 71a83e6578f910c3baa251e4128208b201ce9e45 (patch) | |
| tree | 1605da24b8574a9dfb14f65ea49a4b4c44ba95e8 | |
| parent | 6ae12b03d5566b9119c78d79a96df7ac12b2c636 (diff) | |
Use snac_op in actor_failure().
| -rw-r--r-- | activitypub.c | 10 | ||||
| -rw-r--r-- | data.c | 11 | ||||
| -rw-r--r-- | html.c | 2 | ||||
| -rw-r--r-- | snac.h | 10 |
4 files changed, 22 insertions, 11 deletions
diff --git a/activitypub.c b/activitypub.c index 92eb7f5..4de0be7 100644 --- a/activitypub.c +++ b/activitypub.c @@ -3054,7 +3054,7 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req) followed_hashtag_distribute(a_msg); /* actor is [back] alive */ - actor_failure(who, 2); + actor_failure(who, OP_DEL); do_notify = 1; } @@ -3461,7 +3461,7 @@ void process_user_queue_item(snac *user, xs_dict *q_item) const char *actor = xs_dict_get(q_item, "actor"); double mtime = object_mtime(actor); - if (actor_failure(actor, 0) == -1) { + if (actor_failure(actor, OP_CHECK) == -1) { /* actor is broken beyond repair */ snac_debug(user, 1, xs_fmt("actor_refresh skipped broken actor %s", actor)); } @@ -3478,16 +3478,16 @@ void process_user_queue_item(snac *user, xs_dict *q_item) actor_add(actor, actor_o); /* mark actor and instance as working */ - actor_failure(actor, 2); + actor_failure(actor, OP_DEL); instance_failure(actor, 2); } else { if (status == HTTP_STATUS_GONE || status == HTTP_STATUS_NOT_FOUND) { - actor_failure(actor, 1); + actor_failure(actor, OP_ADD); snac_log(user, xs_fmt("actor_refresh marking actor %s as broken %d", actor, status)); } else { - actor_failure(actor, 2); + actor_failure(actor, OP_DEL); object_touch(actor); } } @@ -3233,7 +3233,7 @@ xs_list *content_search(snac *user, const char *regex, } -int actor_failure(const char *actor, int op) +int actor_failure(const char *actor, snac_op op) /* actor failure maintenance */ { int ret = 0; @@ -3242,13 +3242,13 @@ int actor_failure(const char *actor, int op) xs *fn = xs_fmt("%s/failure/%s", srv_basedir, md5); switch (op) { - case 0: /** check **/ + case OP_CHECK: /** check **/ if (mtime(fn)) ret = -1; break; - case 1: /** register a failure **/ + case OP_ADD: /** register a failure **/ if (mtime(fn) == 0.0) { FILE *f; @@ -3261,11 +3261,14 @@ int actor_failure(const char *actor, int op) break; - case 2: /** clear a failure **/ + case OP_DEL: /** clear a failure **/ /* called whenever a message comes from this instance */ unlink(fn); break; + + default: + break; } return ret; @@ -362,7 +362,7 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, xs_html_raw("💔"))); } - if (actor_failure(actor_id, 0) == -1) { + if (actor_failure(actor_id, OP_CHECK) == -1) { xs_html_add(actor_icon, xs_html_text(" "), xs_html_tag("span", @@ -79,6 +79,14 @@ typedef struct { enum { THST_STOP, THST_WAIT, THST_IN, THST_QUEUE } th_state[MAX_THREADS]; } srv_state; +typedef enum { + OP_CHECK = 0, + OP_ADD = 1, + OP_DEL = 2, + OP_LIST = 3, + OP_FIND = 4 +} snac_op; + extern srv_state *p_state; enum { @@ -300,7 +308,7 @@ int content_match(const char *file, const xs_dict *msg); xs_list *content_search(snac *user, const char *regex, int priv, int skip, int show, int max_secs, int *timeout); -int actor_failure(const char *actor, int op); +int actor_failure(const char *actor, snac_op op); int instance_failure(const char *url, int op); int grave(const char *objid, int op); |