Set moderation_action to defer for moderators/owners

this is apparently not automatic with Mailman 3
This commit is contained in:
Adam Goldsmith 2024-05-07 02:38:51 -04:00
parent 3a224fcff2
commit c835cc428d

View File

@ -123,6 +123,22 @@ def sync_moderators(
list.remove_moderator(member.address.email) 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 = ""
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( def update_cloudflare_lists(
dry_run: bool, dry_run: bool,
auth_token: str, auth_token: str,
@ -198,11 +214,12 @@ def main(
print(f"Configuring/syncing {name}...") print(f"Configuring/syncing {name}...")
config_list(list, dry_run, **props["config"]) config_list(list, dry_run, **props["config"])
if "moderators" in props:
sync_moderators(list, dry_run, set(props["moderators"]))
sync_members( sync_members(
list, dry_run, set(props["members"]) | set(props.get("moderators", [])) 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()] lists = [list.list_name.lower() for list in domain.get_lists()]
update_cloudflare_lists( update_cloudflare_lists(