diff --git a/data.c b/data.c index 0d85efd..fd5d02c 100644 --- a/data.c +++ b/data.c @@ -1575,11 +1575,24 @@ void purge_server(void) void purge_user(snac *snac) /* do the purge for this user */ { - int priv_days, pub_days; + int priv_days, pub_days, user_days = 0; + char *v; priv_days = xs_number_get(xs_dict_get(srv_config, "timeline_purge_days")); pub_days = xs_number_get(xs_dict_get(srv_config, "local_purge_days")); + if ((v = xs_dict_get(snac->config, "purge_days")) != NULL) + user_days = xs_number_get(v); + + if (user_days) { + /* override admin settings only if they are lesser */ + if (priv_days == 0 || user_days < priv_days) + priv_days = user_days; + + if (pub_days == 0 || user_days < pub_days) + pub_days = user_days; + } + _purge_subdir(snac, "hidden", priv_days); _purge_subdir(snac, "private", priv_days); diff --git a/html.c b/html.c index f163921..8351143 100644 --- a/html.c +++ b/html.c @@ -306,6 +306,9 @@ d_char *html_top_controls(snac *snac, d_char *s) "

%s:
\n" "

\n" + "

%s:
\n" + "

\n" + "

%s:
\n" "

\n" @@ -329,6 +332,12 @@ d_char *html_top_controls(snac *snac, d_char *s) if (xs_is_null(cw)) cw = ""; + const char *purge_days = xs_dict_get(snac->config, "purge_days"); + if (!xs_is_null(purge_days) && xs_type(purge_days) == XSTYPE_NUMBER) + purge_days = xs_number_str(purge_days); + else + purge_days = "0"; + xs *s1 = xs_fmt(_tmpl, snac->actor, L("Sensitive content"), @@ -355,6 +364,8 @@ d_char *html_top_controls(snac *snac, d_char *s) L("Always show sensitive content"), L("Email address for notifications"), email, + L("Maximum days to keep posts (0: server settings)"), + purge_days, L("Password (only to change it)"), L("Repeat Password"), L("Update user info") @@ -1567,6 +1578,10 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, } if ((v = xs_dict_get(p_vars, "email")) != NULL) snac.config = xs_dict_set(snac.config, "email", v); + if ((v = xs_dict_get(p_vars, "purge_days")) != NULL) { + xs *days = xs_number_new(atof(v)); + snac.config = xs_dict_set(snac.config, "purge_days", days); + } /* password change? */ if ((p1 = xs_dict_get(p_vars, "passwd1")) != NULL && diff --git a/snac.h b/snac.h index 8617e32..da4f7cd 100644 --- a/snac.h +++ b/snac.h @@ -1,7 +1,7 @@ /* snac - A simple, minimalistic ActivityPub instance */ /* copyright (c) 2022 - 2023 grunfink / MIT license */ -#define VERSION "2.20" +#define VERSION "2.21-dev" #define USER_AGENT "snac/" VERSION