snac2

Fork of https://codeberg.org/grunfink/snac2
git clone https://git.inz.fi/snac2
Log | Files | Refs | README | LICENSE

commit f8c62fe2102c28e9a59bf4cf14ad6b893753a8d3
parent 5afa5ab071fc253cd11f8549de4ae8a5584451ad
Author: default <nobody@localhost>
Date:   Mon, 18 Sep 2023 22:52:27 +0200

Pinned posts are never purged.

Diffstat:
Mdata.c | 8+++++++-
Mhtml.c | 2+-
Msnac.h | 1+
3 files changed, 9 insertions(+), 2 deletions(-)

diff --git 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 @@ -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 @@ -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);