Move list config into "config" and don't config lists when absent

This commit is contained in:
Adam Goldsmith 2023-02-03 14:01:41 -05:00
parent 848c98c456
commit 2e612837c7

View File

@ -3,12 +3,14 @@
""" """
Update Mailman 2 lists via a json API of the form: Update Mailman 2 lists via a json API of the form:
{ {
"LIST": { LIST: {
"real_name": "REAL_NAME", "config"?: {
"moderator": ["ADDRESS", ...], "real_name": REAL_NAME,
"subject_prefix": "PREFIX", "moderator": [ADDRESS, ...],
"reply_to_address": "REPLY_TO_ADDRESS", "subject_prefix": PREFIX,
"members": ["ADDRESS", ...] "reply_to_address": REPLY_TO_ADDRESS,
}
"members": [ADDRESS, ...]
}, },
... ...
} }
@ -90,7 +92,7 @@ class ListManager:
"new_member_options = 272", "new_member_options = 272",
"advertised = 0", "advertised = 0",
"subscribe_policy = 3", # require approval to join "subscribe_policy = 3", # require approval to join
"unsubscribe_policy = 1", # require approval to unsubscribe "unsubscribe_policy = 1", # require approval to unsubscribe
"private_roster = 2", # only admins can view the roster "private_roster = 2", # only admins can view the roster
"default_member_moderation = 1", "default_member_moderation = 1",
"generic_nonmember_action = 3", # discard non-member emails "generic_nonmember_action = 3", # discard non-member emails
@ -161,14 +163,11 @@ def main(
else: else:
list_manager.newlist(urlhost, emailhost, admin) list_manager.newlist(urlhost, emailhost, admin)
print(f"Configuring/syncing {list_name}...") if "config" in props:
list_manager.config_list( print(f"Configuring/syncing {list_name}...")
emailhost, list_manager.config_list(emailhost, **props["config"])
props["real_name"], else:
props["moderator"], print("Not configuring {list_name}, as it has no config section")
props["subject_prefix"],
props["reply_to_address"],
)
list_manager.sync_members(props["members"]) list_manager.sync_members(props["members"])