mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 22:45:05 +00:00
New user option 'purge_days'.
This commit is contained in:
parent
143c73500b
commit
70c73d0336
3 changed files with 30 additions and 2 deletions
15
data.c
15
data.c
|
@ -1575,11 +1575,24 @@ void purge_server(void)
|
||||||
void purge_user(snac *snac)
|
void purge_user(snac *snac)
|
||||||
/* do the purge for this user */
|
/* 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"));
|
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"));
|
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, "hidden", priv_days);
|
||||||
_purge_subdir(snac, "private", priv_days);
|
_purge_subdir(snac, "private", priv_days);
|
||||||
|
|
||||||
|
|
15
html.c
15
html.c
|
@ -306,6 +306,9 @@ d_char *html_top_controls(snac *snac, d_char *s)
|
||||||
"<p>%s:<br>\n"
|
"<p>%s:<br>\n"
|
||||||
"<input type=\"text\" name=\"email\" value=\"%s\"></p>\n"
|
"<input type=\"text\" name=\"email\" value=\"%s\"></p>\n"
|
||||||
|
|
||||||
|
"<p>%s:<br>\n"
|
||||||
|
"<input type=\"number\" name=\"purge_days\" value=\"%s\"></p>\n"
|
||||||
|
|
||||||
"<p>%s:<br>\n"
|
"<p>%s:<br>\n"
|
||||||
"<input type=\"password\" name=\"passwd1\" value=\"\"></p>\n"
|
"<input type=\"password\" name=\"passwd1\" value=\"\"></p>\n"
|
||||||
|
|
||||||
|
@ -329,6 +332,12 @@ d_char *html_top_controls(snac *snac, d_char *s)
|
||||||
if (xs_is_null(cw))
|
if (xs_is_null(cw))
|
||||||
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,
|
xs *s1 = xs_fmt(_tmpl,
|
||||||
snac->actor,
|
snac->actor,
|
||||||
L("Sensitive content"),
|
L("Sensitive content"),
|
||||||
|
@ -355,6 +364,8 @@ d_char *html_top_controls(snac *snac, d_char *s)
|
||||||
L("Always show sensitive content"),
|
L("Always show sensitive content"),
|
||||||
L("Email address for notifications"),
|
L("Email address for notifications"),
|
||||||
email,
|
email,
|
||||||
|
L("Maximum days to keep posts (0: server settings)"),
|
||||||
|
purge_days,
|
||||||
L("Password (only to change it)"),
|
L("Password (only to change it)"),
|
||||||
L("Repeat Password"),
|
L("Repeat Password"),
|
||||||
L("Update user info")
|
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)
|
if ((v = xs_dict_get(p_vars, "email")) != NULL)
|
||||||
snac.config = xs_dict_set(snac.config, "email", v);
|
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? */
|
/* password change? */
|
||||||
if ((p1 = xs_dict_get(p_vars, "passwd1")) != NULL &&
|
if ((p1 = xs_dict_get(p_vars, "passwd1")) != NULL &&
|
||||||
|
|
2
snac.h
2
snac.h
|
@ -1,7 +1,7 @@
|
||||||
/* snac - A simple, minimalistic ActivityPub instance */
|
/* snac - A simple, minimalistic ActivityPub instance */
|
||||||
/* copyright (c) 2022 - 2023 grunfink / MIT license */
|
/* copyright (c) 2022 - 2023 grunfink / MIT license */
|
||||||
|
|
||||||
#define VERSION "2.20"
|
#define VERSION "2.21-dev"
|
||||||
|
|
||||||
#define USER_AGENT "snac/" VERSION
|
#define USER_AGENT "snac/" VERSION
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue