From 8c563882844710272045de0676554f61e02783e0 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Tue, 7 May 2024 02:38:51 -0400 Subject: [PATCH] Set `moderation_action` to defer for moderators this is apparently not automatic with Mailman 3 --- mailman_sync.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/mailman_sync.py b/mailman_sync.py index 0132b1e..749dbec 100755 --- a/mailman_sync.py +++ b/mailman_sync.py @@ -123,6 +123,23 @@ def sync_moderators( list.remove_moderator(member.address.email) +def fixup_moderation_actions(list: mailmanclient.MailingList, dry_run: bool): + expected_moderators = list.moderators + for member in list.members: + if member.address in expected_moderators: + moderation_action = "defer" + else: + moderation_action = "" + + if member.moderation_action != moderation_action: + print( + f"Updating Moderation action for {member} ({member.moderation_action} -> {moderation_action}) in list {list}" + ) + if not dry_run: + member.moderation_action = moderation_action + member.save() + + def update_cloudflare_lists( dry_run: bool, auth_token: str, @@ -198,11 +215,12 @@ def main( print(f"Configuring/syncing {name}...") config_list(list, dry_run, **props["config"]) - if "moderators" in props: - sync_moderators(list, dry_run, set(props["moderators"])) sync_members( list, dry_run, set(props["members"]) | set(props.get("moderators", [])) ) + if "moderators" in props: + sync_moderators(list, dry_run, set(props["moderators"])) + fixup_moderation_actions(list, dry_run) lists = [list.list_name.lower() for list in domain.get_lists()] update_cloudflare_lists(