summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data.c15
-rw-r--r--html.c15
-rw-r--r--snac.h2
3 files changed, 30 insertions, 2 deletions
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)
1575void purge_user(snac *snac) 1575void purge_user(snac *snac)
1576/* do the purge for this user */ 1576/* do the purge for this user */
1577{ 1577{
1578 int priv_days, pub_days; 1578 int priv_days, pub_days, user_days = 0;
1579 char *v;
1579 1580
1580 priv_days = xs_number_get(xs_dict_get(srv_config, "timeline_purge_days")); 1581 priv_days = xs_number_get(xs_dict_get(srv_config, "timeline_purge_days"));
1581 pub_days = xs_number_get(xs_dict_get(srv_config, "local_purge_days")); 1582 pub_days = xs_number_get(xs_dict_get(srv_config, "local_purge_days"));
1582 1583
1584 if ((v = xs_dict_get(snac->config, "purge_days")) != NULL)
1585 user_days = xs_number_get(v);
1586
1587 if (user_days) {
1588 /* override admin settings only if they are lesser */
1589 if (priv_days == 0 || user_days < priv_days)
1590 priv_days = user_days;
1591
1592 if (pub_days == 0 || user_days < pub_days)
1593 pub_days = user_days;
1594 }
1595
1583 _purge_subdir(snac, "hidden", priv_days); 1596 _purge_subdir(snac, "hidden", priv_days);
1584 _purge_subdir(snac, "private", priv_days); 1597 _purge_subdir(snac, "private", priv_days);
1585 1598
diff --git a/html.c b/html.c
index f163921..8351143 100644
--- a/html.c
+++ b/html.c
@@ -307,6 +307,9 @@ d_char *html_top_controls(snac *snac, d_char *s)
307 "<input type=\"text\" name=\"email\" value=\"%s\"></p>\n" 307 "<input type=\"text\" name=\"email\" value=\"%s\"></p>\n"
308 308
309 "<p>%s:<br>\n" 309 "<p>%s:<br>\n"
310 "<input type=\"number\" name=\"purge_days\" value=\"%s\"></p>\n"
311
312 "<p>%s:<br>\n"
310 "<input type=\"password\" name=\"passwd1\" value=\"\"></p>\n" 313 "<input type=\"password\" name=\"passwd1\" value=\"\"></p>\n"
311 314
312 "<p>%s:<br>\n" 315 "<p>%s:<br>\n"
@@ -329,6 +332,12 @@ d_char *html_top_controls(snac *snac, d_char *s)
329 if (xs_is_null(cw)) 332 if (xs_is_null(cw))
330 cw = ""; 333 cw = "";
331 334
335 const char *purge_days = xs_dict_get(snac->config, "purge_days");
336 if (!xs_is_null(purge_days) && xs_type(purge_days) == XSTYPE_NUMBER)
337 purge_days = xs_number_str(purge_days);
338 else
339 purge_days = "0";
340
332 xs *s1 = xs_fmt(_tmpl, 341 xs *s1 = xs_fmt(_tmpl,
333 snac->actor, 342 snac->actor,
334 L("Sensitive content"), 343 L("Sensitive content"),
@@ -355,6 +364,8 @@ d_char *html_top_controls(snac *snac, d_char *s)
355 L("Always show sensitive content"), 364 L("Always show sensitive content"),
356 L("Email address for notifications"), 365 L("Email address for notifications"),
357 email, 366 email,
367 L("Maximum days to keep posts (0: server settings)"),
368 purge_days,
358 L("Password (only to change it)"), 369 L("Password (only to change it)"),
359 L("Repeat Password"), 370 L("Repeat Password"),
360 L("Update user info") 371 L("Update user info")
@@ -1567,6 +1578,10 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size,
1567 } 1578 }
1568 if ((v = xs_dict_get(p_vars, "email")) != NULL) 1579 if ((v = xs_dict_get(p_vars, "email")) != NULL)
1569 snac.config = xs_dict_set(snac.config, "email", v); 1580 snac.config = xs_dict_set(snac.config, "email", v);
1581 if ((v = xs_dict_get(p_vars, "purge_days")) != NULL) {
1582 xs *days = xs_number_new(atof(v));
1583 snac.config = xs_dict_set(snac.config, "purge_days", days);
1584 }
1570 1585
1571 /* password change? */ 1586 /* password change? */
1572 if ((p1 = xs_dict_get(p_vars, "passwd1")) != NULL && 1587 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 @@
1/* snac - A simple, minimalistic ActivityPub instance */ 1/* snac - A simple, minimalistic ActivityPub instance */
2/* copyright (c) 2022 - 2023 grunfink / MIT license */ 2/* copyright (c) 2022 - 2023 grunfink / MIT license */
3 3
4#define VERSION "2.20" 4#define VERSION "2.21-dev"
5 5
6#define USER_AGENT "snac/" VERSION 6#define USER_AGENT "snac/" VERSION
7 7