diff options
| author | grunfink <grunfink@comam.es> | 2025-10-24 05:02:28 +0200 |
|---|---|---|
| committer | grunfink <grunfink@comam.es> | 2025-10-24 05:02:28 +0200 |
| commit | 1a42fdc8bd4d5dc045a87108e73dcda4f633266b (patch) | |
| tree | 0fad3d6cc5f6eff50edb610ef6d44acb6fdc598b | |
| parent | 2dbd5220ac3f7944588051826b008ea1795ff76c (diff) | |
Keep track of deleted users and return 410 Gone for them.
| -rw-r--r-- | activitypub.c | 10 | ||||
| -rw-r--r-- | data.c | 29 | ||||
| -rw-r--r-- | html.c | 5 | ||||
| -rw-r--r-- | httpd.c | 3 | ||||
| -rw-r--r-- | snac.h | 2 | ||||
| -rw-r--r-- | utils.c | 2 |
6 files changed, 45 insertions, 6 deletions
diff --git a/activitypub.c b/activitypub.c index 2d53cbe..0368ac8 100644 --- a/activitypub.c +++ b/activitypub.c @@ -3660,8 +3660,9 @@ int activitypub_get_handler(const xs_dict *req, const char *q_path, uid = xs_list_get(l, 1); if (!user_open(&snac, uid)) { /* invalid user */ - srv_debug(1, xs_fmt("activitypub_get_handler bad user %s", uid)); - return HTTP_STATUS_NOT_FOUND; + status = grave(uid, 0) ? HTTP_STATUS_GONE : HTTP_STATUS_NOT_FOUND; + srv_debug(1, xs_fmt("activitypub_get_handler bad user %s %d", uid, status)); + return status; } p_path = xs_list_get(l, 2); @@ -3854,8 +3855,9 @@ int activitypub_post_handler(const xs_dict *req, const char *q_path, const char *uid = xs_list_get(l, 1); if (!user_open(&snac, uid)) { /* invalid user */ - srv_debug(1, xs_fmt("activitypub_post_handler bad user %s", uid)); - return HTTP_STATUS_NOT_FOUND; + status = grave(uid, 0) ? HTTP_STATUS_GONE : HTTP_STATUS_NOT_FOUND; + srv_debug(1, xs_fmt("activitypub_post_handler bad user %s %d", uid, status)); + return status; } /* if it has a digest, check it now, because @@ -3137,6 +3137,35 @@ int instance_failure(const char *url, int op) } +int grave(const char *objid, int op) +/* the graveyeard of deleted objects */ +{ + int ret = 0; + xs *dir = xs_fmt("%s/grave", srv_basedir); + xs *md5 = xs_md5_hex(objid, strlen(objid)); + xs *fn = xs_fmt("%s/%s", dir, md5); + FILE *f; + + switch (op) { + case 0: /** check **/ + ret = mtime(fn) > 0.0 ? 1 : 0; + break; + + case 1: /** add **/ + mkdirx(dir); + + if ((f = fopen(fn, "w")) != NULL) { + fprintf(f, "%s\n", objid); + fclose(f); + } + + break; + } + + return ret; +} + + /** notifications **/ xs_str *notify_check_time(snac *snac, int reset) @@ -3830,8 +3830,9 @@ int html_get_handler(const xs_dict *req, const char *q_path, if (!uid || !user_open(&snac, uid)) { /* invalid user */ - srv_debug(1, xs_fmt("html_get_handler bad user %s", uid)); - return HTTP_STATUS_NOT_FOUND; + status = grave(uid, 0) ? HTTP_STATUS_GONE : HTTP_STATUS_NOT_FOUND; + srv_debug(1, xs_fmt("html_get_handler bad user %s %d", uid, status)); + return status; } user = &snac; /* for L() */ @@ -598,6 +598,9 @@ void httpd_connection(FILE *f) if (status == HTTP_STATUS_NOT_FOUND) body = xs_str_new("<h1>404 Not Found (" USER_AGENT ")</h1>"); + if (status == HTTP_STATUS_GONE) + body = xs_str_new("<h1>410 Gone (" USER_AGENT ")</h1>"); + if (status == HTTP_STATUS_BAD_REQUEST && body != NULL) body = xs_str_new("<h1>400 Bad Request (" USER_AGENT ")</h1>"); @@ -288,6 +288,8 @@ xs_list *content_search(snac *user, const char *regex, int actor_failure(const char *actor, int op); int instance_failure(const char *url, int op); +int grave(const char *objid, int op); + void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries); void enqueue_shared_input(const xs_dict *msg, const xs_dict *req, int retries); void enqueue_output_raw(const char *keyid, const char *seckey, @@ -454,6 +454,8 @@ int deluser(snac *user) } } + grave(user->uid, 1); + rm_rf(user->basedir); return ret; |