Add a missing template.

This commit is contained in:
Andrea Dell'Amico 2026-08-21 16:54:53 +02:00
parent 9d2e4c48d0
commit 13f6679de3
Signed by: adellam
GPG Key ID: 147ABE6CEB9E20FF
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
"""Seed configured header matches on otherwise unconfigured mailing lists."""
from json import loads
from mailman.interfaces.mailinglist import IHeaderMatchList
RULES = loads({{ mailman_empty_list_header_matches | to_json | to_json }})
def apply(mlist):
"""Add all configured rules if *mlist* has no header matches."""
header_matches = IHeaderMatchList(mlist)
existing_count = len(header_matches)
if existing_count:
print('SKIPPED {} existing_header_matches={}'.format(
mlist.fqdn_listname, existing_count))
return
for rule in RULES:
header_matches.append(
rule['header'],
rule['pattern'],
chain=rule.get('action'),
tag=rule.get('tag'))
print('CHANGED {} added_header_matches={}'.format(
mlist.fqdn_listname, len(RULES)))