diff options
Diffstat (limited to 'Mailman/Queue/CommandRunner.py')
-rw-r--r-- | Mailman/Queue/CommandRunner.py | 58 |
1 files changed, 43 insertions, 15 deletions
diff --git a/Mailman/Queue/CommandRunner.py b/Mailman/Queue/CommandRunner.py index 3155f22f..b63b050c 100644 --- a/Mailman/Queue/CommandRunner.py +++ b/Mailman/Queue/CommandRunner.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2010 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2011 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 @@ -46,6 +46,10 @@ from email.MIMEText import MIMEText from email.MIMEMessage import MIMEMessage NL = '\n' +CONTINUE = 0 +STOP = 1 +BADCMD = 2 +BADSUBJ = 3 try: True, False @@ -105,15 +109,19 @@ class Results: def process(self): # Now, process each line until we find an error. The first # non-command line found stops processing. - stop = False + found = BADCMD + ret = CONTINUE for line in self.commands: if line and line.strip(): args = line.split() cmd = args.pop(0).lower() - stop = self.do_command(cmd, args) + ret = self.do_command(cmd, args) + if ret == STOP or ret == CONTINUE: + found = ret self.lineno += 1 - if stop: + if ret == STOP or ret == BADCMD: break + return found def do_command(self, cmd, args=None): if args is None: @@ -136,8 +144,14 @@ class Results: self.subjcmdretried += 1 cmd = args.pop(0) return self.do_command(cmd, args) - return self.lineno <> 0 - return handler.process(self, args) + if self.lineno <> 0: + return BADCMD + else: + return BADSUBJ + if handler.process(self, args): + return STOP + else: + return CONTINUE def send_response(self): # Helper @@ -156,7 +170,7 @@ Attached is your original message. # Ignore empty lines unprocessed = [line for line in self.commands[self.lineno:] if line and line.strip()] - if unprocessed: + if unprocessed and mm_cfg.RESPONSE_INCLUDE_LEVEL >= 2: resp.append(_('\n- Unprocessed:')) resp.extend(indent(unprocessed)) if not unprocessed and not self.results: @@ -165,7 +179,7 @@ Attached is your original message. No commands were found in this message. To obtain instructions, send a message containing just the word "help". """))) - if self.ignored: + if self.ignored and mm_cfg.RESPONSE_INCLUDE_LEVEL >= 2: resp.append(_('\n- Ignored:')) resp.extend(indent(self.ignored)) resp.append(_('\n- Done.\n\n')) @@ -196,7 +210,15 @@ To obtain instructions, send a message containing just the word "help". lang=self.msgdata['lang']) msg.set_type('multipart/mixed') msg.attach(results) - orig = MIMEMessage(self.msg) + if mm_cfg.RESPONSE_INCLUDE_LEVEL == 1: + self.msg.set_payload( + _('Message body suppressed by Mailman site configuration\n')) + if mm_cfg.RESPONSE_INCLUDE_LEVEL == 0: + orig = MIMEText(_( + 'Original message suppressed by Mailman site configuration\n' + ), _charset=charset) + else: + orig = MIMEMessage(self.msg) msg.attach(orig) msg.send(self.mlist) @@ -236,17 +258,23 @@ class CommandRunner(Runner): # mylist-join, or mylist-leave, and the message metadata will contain # a key to which one was used. try: + ret = BADCMD if msgdata.get('torequest'): - res.process() + ret = res.process() elif msgdata.get('tojoin'): - res.do_command('join') + ret = res.do_command('join') elif msgdata.get('toleave'): - res.do_command('leave') + ret = res.do_command('leave') elif msgdata.get('toconfirm'): mo = re.match(mm_cfg.VERP_CONFIRM_REGEXP, msg.get('to', '')) if mo: - res.do_command('confirm', (mo.group('cookie'),)) - res.send_response() - mlist.Save() + ret = res.do_command('confirm', (mo.group('cookie'),)) + if ret == BADCMD and mm_cfg.DISCARD_MESSAGE_WITH_NO_COMMAND: + syslog('vette', + 'No command, message discarded, msgid: %s', + msg.get('message-id', 'n/a')) + else: + res.send_response() + mlist.Save() finally: mlist.Unlock() |