summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcron/checkdbs49
-rw-r--r--cron/disabled7
-rwxr-xr-xcron/mailpasswds15
3 files changed, 52 insertions, 19 deletions
diff --git a/cron/checkdbs b/cron/checkdbs
index 5f1b9b3c3..126981093 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,27 @@ 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)
- subject = _(
- '%(count)d %(realname)s moderator request(s) waiting')
+ 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')
+ else:
+ subject = _(
+ '%(realname)s moderator request check result')
msg = Message.UserNotification(mlist.GetOwnerEmail(),
mlist.GetBouncesEmail(),
subject, text,
@@ -122,6 +135,7 @@ def main():
def pending_requests(mlist):
# Must return a byte string
+ lcset = Utils.GetCharSet(mlist.preferred_language)
pending = []
first = 1
for id in mlist.GetSubscriptionIds():
@@ -130,6 +144,8 @@ def pending_requests(mlist):
first = 0
when, addr, fullname, passwd, digest, lang = mlist.GetRecord(id)
if fullname:
+ if isinstance(fullname, UnicodeType):
+ fullname = fullname.encode(lcset, 'replace')
fullname = ' (%s)' % fullname
pending.append(' %s%s %s' % (addr, fullname, time.ctime(when)))
first = 1
@@ -139,6 +155,7 @@ def pending_requests(mlist):
first = 0
info = mlist.GetRecord(id)
when, sender, subject, reason, text, msgdata = mlist.GetRecord(id)
+ subject = Utils.oneline(subject, lcset)
date = time.ctime(when)
reason = _(reason)
pending.append(_("""\
@@ -168,6 +185,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__':
diff --git a/cron/disabled b/cron/disabled
index 9dd4da838..6624ff21f 100644
--- a/cron/disabled
+++ b/cron/disabled
@@ -1,6 +1,6 @@
#! @PYTHON@
#
-# Copyright (C) 2001-2003 by the Free Software Foundation, Inc.
+# Copyright (C) 2001-2004 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -189,8 +189,9 @@ def main():
info = _BounceInfo(
member, 0, today,
mlist.bounce_you_are_disabled_warnings,
- Pending.new(Pending.RE_ENABLE, mlist.internal_name(),
- member))
+ mlist.pend_new(Pending.RE_ENABLE,
+ mlist.internal_name(),
+ member))
mlist.setBounceInfo(member, info)
lastnotice = time.mktime(info.lastnotice + (0,) * 6)
if force or today >= lastnotice + interval:
diff --git a/cron/mailpasswds b/cron/mailpasswds
index c2563e690..5745265a1 100755
--- a/cron/mailpasswds
+++ b/cron/mailpasswds
@@ -193,9 +193,6 @@ def main():
poplang = lang
langcnt = cnt
enc = Utils.GetCharSet(poplang)
- # Craft the table header
- header = '%-40s %-10s\n%-40s %-10s' % (
- _('List'), _('Password // URL'), '----', '--------')
# Now we're finally ready to send the email!
siteowner = Utils.get_site_email(host, 'owner')
sitereq = Utils.get_site_email(host, 'request')
@@ -210,16 +207,22 @@ def main():
# Coerce everything to Unicode
text = tounicode(text, enc)
table = [tounicode(_t, enc) for _t in table]
- # Add the table to the end so it doesn't get wrapped/filled
- text += (header + '\n' + NL.join(table))
# Translate the message and headers to user's suggested lang
otrans = i18n.get_translation()
try:
i18n.set_language(poplang)
+ # Craft table header after language was set
+ header = '%-40s %-10s\n%-40s %-10s' % (
+ _('List'), _('Password // URL'), '----', '--------')
+ header = tounicode(header, enc)
+ # Add the table to the end so it doesn't get wrapped/filled
+ text += (header + '\n' + NL.join(table))
msg = Message.UserNotification(
addr, siteowner,
_('%(host)s mailing list memberships reminder'),
- text, poplang)
+ text.encode(enc, 'replace'), poplang)
+ # Note that text must be encoded into 'enc' because unicode
+ # cause error within email module in some language (Japanese).
finally:
i18n.set_translation(otrans)
msg['X-No-Archive'] = 'yes'