From 8d7c7778956ac166c76320272017ba0f25b735c2 Mon Sep 17 00:00:00 2001
From: Art Cancro
The final set of options configures system-wide defaults for the auto-purger:
-Default user purge time (days) [120]:+
Default room purge time (days) [30]:
System default message expire policy (? for list) [2]:
Keep how many messages online? [150]:
Default user purge time (days) [120]:
+Default room purge time (days) [30]:
+System default message expire policy (? for list) [2]:
+Keep how many messages online? [150]:
+Mailbox default message expire policy (? for list) [1]:
+
Any user who does not log in for the period specified in 'Default user purge time' will be deleted the next time a purge is run. This setting may be modified on a per-user basis.
@@ -1619,7 +1624,11 @@ messages are expired (purged) off the system. You can specify any of:Again, this setting may be overridden on a per-floor basis, and the -floor setting may be overridden on a per-room basis.
+floor setting may be overridden on a per-room basis. You'll also notice +that you can set a different default for mailbox rooms if you want +to. This can allow you, for example, to set a policy under which old +messages scroll out of public rooms, but private mail stays online indefinitely +until deleted by the mailbox owners.Save this configuration? No
When you're done, enter 'Yes' to confirm the changes, or 'No' to discard the changes.
diff --git a/citadel/policy.c b/citadel/policy.c index 621e7a72a..7ad326c3c 100644 --- a/citadel/policy.c +++ b/citadel/policy.c @@ -53,11 +53,26 @@ void GetExpirePolicy(struct ExpirePolicy *epbuf, struct ctdlroom *qrbuf) { return; } - /* Otherwise, if the floor has its own policy, return it */ - fl = cgetfloor(qrbuf->QRfloor); - if (fl->f_ep.expire_mode != 0) { - memcpy(epbuf, &fl->f_ep, sizeof(struct ExpirePolicy)); - return; + /* (non-mailbox rooms) + * If the floor has its own policy, return it + */ + if ( (qrbuf->QRflags & QR_MAILBOX) == 0) { + fl = cgetfloor(qrbuf->QRfloor); + if (fl->f_ep.expire_mode != 0) { + memcpy(epbuf, &fl->f_ep, sizeof(struct ExpirePolicy)); + return; + } + } + + /* (Mailbox rooms) + * If there is a default policy for mailbox rooms, return it + */ + if (qrbuf->QRflags & QR_MAILBOX) { + if (&config.c_mbxep.expire_mode != 0) { + memcpy(epbuf, &config.c_mbxep, + sizeof(struct ExpirePolicy)); + return; + } } /* Otherwise, fall back on the system default */ @@ -81,6 +96,9 @@ void cmd_gpex(char *argbuf) { fl = cgetfloor(CC->room.QRfloor); memcpy(&exp, &fl->f_ep, sizeof(struct ExpirePolicy)); } + else if (!strcasecmp(which, "mailboxes")) { + memcpy(&exp, &config.c_mbxep, sizeof(struct ExpirePolicy)); + } else if (!strcasecmp(which, "site")) { memcpy(&exp, &config.c_ep, sizeof(struct ExpirePolicy)); } @@ -138,6 +156,14 @@ void cmd_spex(char *argbuf) { return; } + else if (!strcasecmp(which, "mailboxes")) { + memcpy(&config.c_mbxep, &exp, sizeof(struct ExpirePolicy)); + put_config(); + cprintf("%d Default expire policy for mailboxes set.\n", + CIT_OK); + return; + } + else if (!strcasecmp(which, "site")) { if (exp.expire_mode == EXPIRE_NEXTLEVEL) { cprintf("%d Invalid policy (no higher level)\n", diff --git a/citadel/routines2.c b/citadel/routines2.c index efc81a6e2..c3d4269f9 100644 --- a/citadel/routines2.c +++ b/citadel/routines2.c @@ -645,7 +645,8 @@ void do_system_configuration(CtdlIPC *ipc) char buf[SIZ]; char sc[32][SIZ]; char *resp = NULL; - struct ExpirePolicy *expirepolicy = NULL; + struct ExpirePolicy *site_expirepolicy = NULL; + struct ExpirePolicy *mbx_expirepolicy = NULL; int a; int logpages = 0; int r; /* IPC response code */ @@ -671,7 +672,8 @@ void do_system_configuration(CtdlIPC *ipc) /* Fetch the expire policy (this will silently fail on old servers, * resulting in "default" policy) */ - r = CtdlIPCGetMessageExpirationPolicy(ipc, 2, &expirepolicy, buf); + r = CtdlIPCGetMessageExpirationPolicy(ipc, 2, &site_expirepolicy, buf); + r = CtdlIPCGetMessageExpirationPolicy(ipc, 3, &mbx_expirepolicy, buf); /* Identification parameters */ @@ -751,7 +753,7 @@ void do_system_configuration(CtdlIPC *ipc) /* Angels and demons dancing in my head... */ do { - snprintf(buf, sizeof buf, "%d", expirepolicy->expire_mode); + snprintf(buf, sizeof buf, "%d", site_expirepolicy->expire_mode); strprompt("System default message expire policy (? for list)", buf, 1); if (buf[0] == '?') { @@ -761,18 +763,45 @@ void do_system_configuration(CtdlIPC *ipc) "3. Expire by message age\n"); } } while ((buf[0] < '1') || (buf[0] > '3')); - expirepolicy->expire_mode = buf[0] - '0'; + site_expirepolicy->expire_mode = buf[0] - '0'; /* ...lunatics and monsters underneath my bed */ - if (expirepolicy->expire_mode == 2) { - snprintf(buf, sizeof buf, "%d", expirepolicy->expire_value); + if (site_expirepolicy->expire_mode == 2) { + snprintf(buf, sizeof buf, "%d", site_expirepolicy->expire_value); strprompt("Keep how many messages online?", buf, 10); - expirepolicy->expire_value = atol(buf); + site_expirepolicy->expire_value = atol(buf); } - if (expirepolicy->expire_mode == 3) { - snprintf(buf, sizeof buf, "%d", expirepolicy->expire_value); + if (site_expirepolicy->expire_mode == 3) { + snprintf(buf, sizeof buf, "%d", site_expirepolicy->expire_value); strprompt("Keep messages for how many days?", buf, 10); - expirepolicy->expire_value = atol(buf); + site_expirepolicy->expire_value = atol(buf); + } + + /* Media messiahs preying on my fears... */ + do { + snprintf(buf, sizeof buf, "%d", mbx_expirepolicy->expire_mode); + strprompt("Mailbox default message expire policy (? for list)", + buf, 1); + if (buf[0] == '?') { + scr_printf("\n" + "0. Go with the system default\n" + "1. Never automatically expire messages\n" + "2. Expire by message count\n" + "3. Expire by message age\n"); + } + } while ((buf[0] < '0') || (buf[0] > '3')); + mbx_expirepolicy->expire_mode = buf[0] - '0'; + + /* ...Pop culture prophets playing in my ears */ + if (mbx_expirepolicy->expire_mode == 2) { + snprintf(buf, sizeof buf, "%d", mbx_expirepolicy->expire_value); + strprompt("Keep how many messages online?", buf, 10); + mbx_expirepolicy->expire_value = atol(buf); + } + if (mbx_expirepolicy->expire_mode == 3) { + snprintf(buf, sizeof buf, "%d", mbx_expirepolicy->expire_value); + strprompt("Keep messages for how many days?", buf, 10); + mbx_expirepolicy->expire_value = atol(buf); } strprompt("How often to run network jobs (in seconds)", &sc[28][0], 5); @@ -798,10 +827,17 @@ void do_system_configuration(CtdlIPC *ipc) err_printf("%s\n", buf); } free(resp); - r = CtdlIPCSetMessageExpirationPolicy(ipc, 2, expirepolicy, buf); + + r = CtdlIPCSetMessageExpirationPolicy(ipc, 2, site_expirepolicy, buf); if (r / 100 != 2) { err_printf("%s\n", buf); } + + r = CtdlIPCSetMessageExpirationPolicy(ipc, 3, mbx_expirepolicy, buf); + if (r / 100 != 2) { + err_printf("%s\n", buf); + } + } } diff --git a/citadel/serv_vandelay.c b/citadel/serv_vandelay.c index 5167d6792..831535029 100644 --- a/citadel/serv_vandelay.c +++ b/citadel/serv_vandelay.c @@ -283,6 +283,8 @@ void artv_do_export(void) { cprintf("%d\n", config.c_pop3_port); cprintf("%d\n", config.c_smtp_port); cprintf("%d\n", config.c_purge_hour); + cprintf("%d\n", config.c_mbxep.expire_mode); + cprintf("%d\n", config.c_mbxep.expire_value); /* Export the control file */ get_control(); @@ -340,6 +342,8 @@ void artv_import_config(void) { client_gets(buf); config.c_pop3_port = atoi(buf); client_gets(buf); config.c_smtp_port = atoi(buf); client_gets(buf); config.c_purge_hour = atoi(buf); + client_gets(buf); config.c_mbxep.expire_mode = atoi(buf); + client_gets(buf); config.c_mbxep.expire_value = atoi(buf); put_config(); lprintf(7, "Imported config file\n"); } diff --git a/citadel/techdoc/session.txt b/citadel/techdoc/session.txt index 8722b3ec4..69942b0a8 100644 --- a/citadel/techdoc/session.txt +++ b/citadel/techdoc/session.txt @@ -1690,7 +1690,7 @@ purging (expiration) of messages. The following policies are available: 3 - Purge by message age. (Requires a value: number of days) The format of this command is: GPEX