From 8fac612dda9e863d2ebd2ffe721a5dffbc11cca7 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 `accept` for moderators/owners this is apparently not automatic with Mailman 3 --- mailman_sync.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/mailman_sync.py b/mailman_sync.py index 0132b1e..6085cd7 100755 --- a/mailman_sync.py +++ b/mailman_sync.py @@ -123,6 +123,22 @@ def sync_moderators( list.remove_moderator(member.address.email) +def fixup_moderation_actions(list: mailmanclient.MailingList, dry_run: bool): + for member in list.members: + if list.is_owner_or_mod(member.address): + new_moderation_action = "accept" + else: + new_moderation_action = None + + if member.moderation_action != new_moderation_action: + print( + f"Updating Moderation action for {member} ({member.moderation_action} -> {new_moderation_action}) in list {list}" + ) + if not dry_run: + member.moderation_action = new_moderation_action + member.save() + + def update_cloudflare_lists( dry_run: bool, auth_token: str, @@ -198,11 +214,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(