diff options
| author | tkikuchi | 2005-08-28 05:47:08 +0000 |
|---|---|---|
| committer | tkikuchi | 2005-08-28 05:47:08 +0000 |
| commit | 737468981aa2f191ce243b063418a3bc878b9832 (patch) | |
| tree | a895dfc0492ea44523ae2bf5452b58b8d3afc434 /cron/checkdbs | |
| parent | 1c0c9a0ce8d100157e4c1a21e7e0f8bddc990f50 (diff) | |
| download | mailman-737468981aa2f191ce243b063418a3bc878b9832.tar.gz mailman-737468981aa2f191ce243b063418a3bc878b9832.tar.zst mailman-737468981aa2f191ce243b063418a3bc878b9832.zip | |
back porting from 2.1.6
Diffstat (limited to 'cron/checkdbs')
| -rwxr-xr-x | cron/checkdbs | 49 |
1 files changed, 39 insertions, 10 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__': |
