From 13f6679de367cf8dd16ef435120ee2a821057b8c Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 21 Aug 2026 16:54:53 +0200 Subject: [PATCH] Add a missing template. --- .../seed-empty-list-header-matches.py.j2 | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 templates/seed-empty-list-header-matches.py.j2 diff --git a/templates/seed-empty-list-header-matches.py.j2 b/templates/seed-empty-list-header-matches.py.j2 new file mode 100644 index 0000000..28dedeb --- /dev/null +++ b/templates/seed-empty-list-header-matches.py.j2 @@ -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)))