From f8c62fe2102c28e9a59bf4cf14ad6b893753a8d3 Mon Sep 17 00:00:00 2001 From: default Date: Mon, 18 Sep 2023 22:52:27 +0200 Subject: [PATCH] Pinned posts are never purged. --- data.c | 8 +++++++- html.c | 2 +- snac.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/data.c b/data.c index 2e9f3b7..3b22114 100644 --- a/data.c +++ b/data.c @@ -1343,6 +1343,13 @@ int is_pinned(snac *user, const char *id) } +int is_pinned_by_md5(snac *user, const char *md5) +{ + xs *fn = xs_fmt("%s/pinned/%s.json", user->basedir, md5); + return !!(mtime(fn) != 0.0); +} + + int pin(snac *user, const char *id) /* pins a message */ { @@ -2436,7 +2443,6 @@ void purge_user(snac *snac) _purge_user_subdir(snac, "hidden", priv_days); _purge_user_subdir(snac, "private", priv_days); - _purge_user_subdir(snac, "pinned", pub_days); _purge_user_subdir(snac, "public", pub_days); const char *idxs[] = { "followers.idx", "private.idx", "public.idx", "pinned.idx", NULL }; diff --git a/html.c b/html.c index f967a1e..e8d31a3 100644 --- a/html.c +++ b/html.c @@ -1563,7 +1563,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int local, int skip, int xs *msg = NULL; int status; - if (user) + if (user && !is_pinned_by_md5(user, v)) status = timeline_get_by_md5(user, v, &msg); else status = object_get_by_md5(v, &msg); diff --git a/snac.h b/snac.h index e0d9fcc..9b7f37a 100644 --- a/snac.h +++ b/snac.h @@ -130,6 +130,7 @@ int is_muted(snac *snac, const char *actor); int pin(snac *user, const char *id); int unpin(snac *user, const char *id); int is_pinned(snac *user, const char *id); +int is_pinned_by_md5(snac *user, const char *md5); xs_list *pinned_list(snac *user); int limited(snac *user, const char *id, int cmd);