[Mailman-Users] Discard/Ban all messages pending moderation
Mark Sapiro
mark at msapiro.net
Sat Jun 1 03:42:35 CEST 2013
Mark Sapiro wrote:
> If there are so many that this is unwieldy, you could do this with a
> withlist script. Something along the lines of the following totally
> untested script:
>
> from Mailman import mm_cfg
> def discard(mlist):
> for id in mlist.GetHeldMessageIds():
> sender = mlist.GetRecord(id)[1]
> if sender not in mlist.discard_these_nonmembers:
> mlist.discard_these_nonmembers.append(sender)
> mlist.HandleRequest(id, mm_cfg.DISCARD)
>
>
> See 'bin/withlist --help' for what to do with this.
It occurred to me that there is a problem with the above, namely it
doesn't save the list so it will probably discard all the held messages
but not update discard_these_nonmembers.
The following is still untested, but should be better
from Mailman import mm_cfg
def discard(mlist):
if not mlist.Locked():
mlist.Lock()
for id in mlist.GetHeldMessageIds():
sender = mlist.GetRecord(id)[1]
if sender not in mlist.discard_these_nonmembers:
mlist.discard_these_nonmembers.append(sender)
mlist.HandleRequest(id, mm_cfg.DISCARD)
mlist.Save()
mlist.Unlock()
--
Mark Sapiro <mark at msapiro.net> The highway is for gamblers,
San Francisco Bay Area, California better use your sense - B. Dylan
More information about the Mailman-Users
mailing list