aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortkikuchi <>2004-10-08 12:38:49 +0000
committertkikuchi <>2004-10-08 12:38:49 +0000
commit0d4f2ad7808f1c3a26a7d4ccc996801efdffc58c (patch)
treeb3b1a3987bc947485e6eeee2d7cad84c99c5f726
parent07f03ba6cc18371f18bd66d7c51fe4aacd4dae0c (diff)
downloadmailman2-0d4f2ad7808f1c3a26a7d4ccc996801efdffc58c.tar.gz
mailman2-0d4f2ad7808f1c3a26a7d4ccc996801efdffc58c.tar.xz
mailman2-0d4f2ad7808f1c3a26a7d4ccc996801efdffc58c.zip
[ 790494 ] built-in automatic discard
-rw-r--r--Mailman/Defaults.py.in3
-rw-r--r--Mailman/Gui/General.py7
-rw-r--r--Mailman/MailList.py2
-rw-r--r--Mailman/Version.py2
-rw-r--r--Mailman/versions.py2
-rwxr-xr-xcron/checkdbs41
6 files changed, 47 insertions, 10 deletions
diff --git a/Mailman/Defaults.py.in b/Mailman/Defaults.py.in
index bc1c4538..bb9d4e07 100644
--- a/Mailman/Defaults.py.in
+++ b/Mailman/Defaults.py.in
@@ -819,6 +819,9 @@ DEFAULT_ADMIN_IMMED_NOTIFY = Yes
# Is the list owner notified of subscribes/unsubscribes?
DEFAULT_ADMIN_NOTIFY_MCHANGES = No
+# Discard held messages after this days
+DEFAULT_MAX_DAYS_TO_HOLD = 3 # days
+
# Should list members, by default, have their posts be moderated?
DEFAULT_DEFAULT_MEMBER_MODERATION = No
diff --git a/Mailman/Gui/General.py b/Mailman/Gui/General.py
index 7cf1ee06..4b587e05 100644
--- a/Mailman/Gui/General.py
+++ b/Mailman/Gui/General.py
@@ -409,6 +409,13 @@ class General(GUIBase):
headers.)"""))
)
+ # Discard held messages after this number of days
+ rtn.append(
+ ('max_days_to_hold', mm_cfg.Number, 7, 0,
+ _("""Discard held messages older than this number of days.
+ Use 0 for no automatic discarding."""))
+ )
+
return rtn
def _setValue(self, mlist, property, val, doc):
diff --git a/Mailman/MailList.py b/Mailman/MailList.py
index 7eee3524..d44350ca 100644
--- a/Mailman/MailList.py
+++ b/Mailman/MailList.py
@@ -387,6 +387,8 @@ class MailList(HTMLFormatter, Deliverer, ListAdmin,
self.encode_ascii_prefixes = 2
# scrub regular delivery
self.scrub_nondigest = mm_cfg.DEFAULT_SCRUB_NONDIGEST
+ # automatic discarding
+ self.max_days_to_hold = mm_cfg.DEFAULT_MAX_DAYS_TO_HOLD
#
diff --git a/Mailman/Version.py b/Mailman/Version.py
index eebd4094..f7dad1ea 100644
--- a/Mailman/Version.py
+++ b/Mailman/Version.py
@@ -36,7 +36,7 @@ HEX_VERSION = ((MAJOR_REV << 24) | (MINOR_REV << 16) | (MICRO_REV << 8) |
(REL_LEVEL << 4) | (REL_SERIAL << 0))
# config.pck schema version number
-DATA_FILE_VERSION = 91
+DATA_FILE_VERSION = 92
# qfile/*.db schema version number
QFILE_SCHEMA_VERSION = 3
diff --git a/Mailman/versions.py b/Mailman/versions.py
index 02a16e7e..2faee667 100644
--- a/Mailman/versions.py
+++ b/Mailman/versions.py
@@ -400,6 +400,8 @@ def NewVars(l):
add_only_if_missing('filter_filename_extensions',
mm_cfg.DEFAULT_FILTER_FILENAME_EXTENSIONS)
add_only_if_missing('pass_filename_extensions', [])
+ # automatic discard
+ add_only_if_missing('max_days_to_hold', 0)
diff --git a/cron/checkdbs b/cron/checkdbs
index 1c867c53..e2b2ebfd 100755
--- a/cron/checkdbs
+++ b/cron/checkdbs
@@ -52,6 +52,8 @@ PROGRAM = sys.argv[0]
_ = i18n._
i18n.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE)
+now = time.time()
+
def usage(code, msg=''):
@@ -99,16 +101,24 @@ def main():
if count:
i18n.set_language(mlist.preferred_language)
realname = mlist.real_name
- text = Utils.maketext(
- 'checkdbs.txt',
- {'count' : count,
- 'host_name': mlist.host_name,
- 'adminDB' : mlist.GetScriptURL('admindb', absolute=1),
- 'real_name': realname,
- }, mlist=mlist)
- text += '\n' + pending_requests(mlist)
+ discarded = auto_discard(mlist)
+ if discarded:
+ count = count - discarded
+ text = _(
+ 'Notice: %(discarded)d old request(s) automatically expired.\n\n')
+ else:
+ text = ''
+ if count:
+ text += Utils.maketext(
+ 'checkdbs.txt',
+ {'count' : count,
+ 'host_name': mlist.host_name,
+ 'adminDB' : mlist.GetScriptURL('admindb', absolute=1),
+ 'real_name': realname,
+ }, mlist=mlist)
+ text += '\n' + pending_requests(mlist)
subject = _(
- '%(count)d %(realname)s moderator request(s) waiting')
+ '%(realname)s moderator requests notice')
msg = Message.UserNotification(mlist.GetOwnerEmail(),
mlist.GetBouncesEmail(),
subject, text,
@@ -121,6 +131,7 @@ def main():
def pending_requests(mlist):
+ lcset = Utils.GetCharSet(mlist.preferred_language)
# Must return a byte string
lcset = Utils.GetCharSet(mlist.preferred_language)
pending = []
@@ -172,6 +183,18 @@ Cause: %(reason)s"""))
utext = unicode(text, incodec, 'replace')
return utext.encode(outcodec, 'replace')
+def auto_discard(mlist):
+ # Discard old held messages
+ discard_count = 0
+ expire = mlist.max_days_to_hold * 86400 # days
+ heldmsgs = mlist.GetHeldMessageIds()
+ if expire and len(heldmsgs):
+ for id in heldmsgs:
+ if now - mlist.GetRecord(id)[0] > expire:
+ mlist.HandleRequest(id, mm_cfg.DISCARD)
+ discard_count += 1
+ mlist.Save()
+ return discard_count
if __name__ == '__main__':