diff options
| author | Barry Warsaw | 2008-01-14 23:22:15 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2008-01-14 23:22:15 -0500 |
| commit | 0bf7659000d2736839919c1ac2adc99b9bcb1b46 (patch) | |
| tree | 7ebc75fb36da6f5de9e8626ae5f05bc52bd81ac1 /Mailman/app/replybot.py | |
| parent | a077406487020ecf8dfb7b27e931ca7eb9f5d3b2 (diff) | |
| download | mailman-0bf7659000d2736839919c1ac2adc99b9bcb1b46.tar.gz mailman-0bf7659000d2736839919c1ac2adc99b9bcb1b46.tar.zst mailman-0bf7659000d2736839919c1ac2adc99b9bcb1b46.zip | |
Diffstat (limited to 'Mailman/app/replybot.py')
| -rw-r--r-- | Mailman/app/replybot.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Mailman/app/replybot.py b/Mailman/app/replybot.py index c46931770..d1bc9c487 100644 --- a/Mailman/app/replybot.py +++ b/Mailman/app/replybot.py @@ -25,6 +25,7 @@ from __future__ import with_statement __all__ = [ 'autorespond_to_sender', + 'can_acknowledge', ] import logging @@ -87,3 +88,36 @@ def autorespond_to_sender(mlist, sender, lang=None): mlist.hold_and_cmd_autoresponses[sender] = (today, count + 1) return True + + +def can_acknowledge(msg): + """A boolean specifying whether this message can be acknowledged. + + There are several reasons why a message should not be acknowledged, mostly + related to competing standards or common practices. These include: + + * The message has a X-No-Ack header with any value + * The message has an X-Ack header with a 'no' value + * The message has a Precedence header + * The message has an Auto-Submitted header and that header does not have a + value of 'no' + * The message has an empty Return-Path header, e.g. <> + * The message has any RFC 2369 headers (i.e. List-* headers) + + :param msg: a Message object. + :return: Boolean specifying whether the message can be acknowledged or not + (which is different from whether it will be acknowledged). + """ + # I wrote it this way for clarity and consistency with the docstring. + for header in msg: + if header in ('x-no-ack', 'precedence'): + return False + if header.lower().startswith('list-'): + return False + if msg.get('x-ack', '').lower() == 'no': + return False + if msg.get('auto-submitted', 'no').lower() <> 'no' + return False + if msg.get('return-path') == '<>': + return False + return True |
