diff options
| author | Barry Warsaw | 2015-10-20 22:58:33 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2015-10-20 22:58:33 -0400 |
| commit | 724b7cee7ed92a8107733cdef2906ef9c0d69f56 (patch) | |
| tree | 42e12a19ac1cb1915cbf801b223ce0c4a92a74d7 /src/mailman/interfaces/mailinglist.py | |
| parent | 49d17bc04386293b3f659e24070f618f5f1b3b05 (diff) | |
| parent | 5104e712380acca2faef5cfd7dc24a3ffc82bfbe (diff) | |
| download | mailman-724b7cee7ed92a8107733cdef2906ef9c0d69f56.tar.gz mailman-724b7cee7ed92a8107733cdef2906ef9c0d69f56.tar.zst mailman-724b7cee7ed92a8107733cdef2906ef9c0d69f56.zip | |
Mailing lists can now have their own header matching rules, although
site-defined rules still take precedence. Importing a Mailman 2.1 list with
header matching rules defined will create them in Mailman 3, albeit with a few
unsupported corner cases. Definition of new header matching rules is not yet
exposed through the REST API. Given by Aurélien Bompard.
Code cleaning pass by Barry Warsaw.
Closes !42
Diffstat (limited to 'src/mailman/interfaces/mailinglist.py')
| -rw-r--r-- | src/mailman/interfaces/mailinglist.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/mailman/interfaces/mailinglist.py b/src/mailman/interfaces/mailinglist.py index f112b2a11..0be8c2b68 100644 --- a/src/mailman/interfaces/mailinglist.py +++ b/src/mailman/interfaces/mailinglist.py @@ -20,6 +20,7 @@ __all__ = [ 'IAcceptableAlias', 'IAcceptableAliasSet', + 'IHeaderMatch', 'IListArchiver', 'IListArchiverSet', 'IMailingList', @@ -839,3 +840,61 @@ class IListArchiverSet(Interface): :return: the matching `IListArchiver` or None if the named archiver does not exist. """ + + + +class IHeaderMatch(Interface): + """A mailing list-specific message header matching rule.""" + + mailing_list = Attribute( + """The mailing list for the header match.""") + + header = Attribute( + """The email header that will be checked.""") + + pattern = Attribute( + """The regular expression to match.""") + + chain = Attribute( + """The chain to jump to on a match. + + If it is None, the `[antispam]jump_chain` action in the configuration + file is used. + """) + + +class IHeaderMatchSet(Interface): + """The set of header matching rules for a mailing list.""" + + def clear(): + """Clear the set of header matching rules.""" + + def add(header, pattern, chain=None): + """Add the given header matching rule to this mailing list's set. + + :param header: The email header to filter on. It will be converted to + lower case for consistency. + :type header: string + :param pattern: The regular expression to use. + :type pattern: string + :param chain: The chain to jump to, or None to use the site-wide + configuration. Defaults to None. + :type chain: string or None + :raises ValueError: if the header/pattern pair already exists for this + mailing list. + """ + + def remove(header, pattern): + """Remove the given header matching rule from this mailing list's set. + + :param header: The email header part of the rule to be removed. + :type header: string + :param pattern: The regular expression part of the rule to be removed. + :type pattern: string + """ + + def __iter__(): + """An iterator over all the IHeaderMatches defined in this set. + + :return: iterator over `IHeaderMatch`. + """ |
