Configure more list properties based on expanded API

This commit is contained in:
Adam Goldsmith 2023-01-19 15:51:13 -05:00
parent 686bfc7e24
commit c65cd8ea8e

View File

@ -1,7 +1,17 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
""" """
Update Mailman 2 lists via a json API of the form {"LIST": ["ADDRESS", ...]} Update Mailman 2 lists via a json API of the form:
{
"LIST": {
"real_name": "REAL_NAME",
"moderator": ["ADDRESS", ...],
"subject_prefix": "PREFIX",
"reply_to_address": "REPLY_TO_ADDRESS",
"members": ["ADDRESS", ...]
},
...
}
""" """
import argparse import argparse
@ -50,13 +60,22 @@ class ListManager:
], ],
) )
def config_list(self): def config_list(
self,
real_name: str,
moderator: list[str],
subject_prefix: str,
reply_to_address: str,
):
config_changes = "\n".join( config_changes = "\n".join(
[ [
# TODO: set real_name, moderator, subject prefix, and reply-to address "real_name = " + repr(real_name),
"moderator = " + repr(moderator),
"subject_prefix = " + repr(subject_prefix),
"from_is_list = 1", "from_is_list = 1",
"anonymous_list = 1", "anonymous_list = 1",
"first_strip_reply_to = 1", "first_strip_reply_to = 1",
"reply_to_address = " + repr(reply_to_address),
# Use explicit address for Reply-To # Use explicit address for Reply-To
"reply_goes_to_list = 2", "reply_goes_to_list = 2",
# quiet member management # quiet member management
@ -124,7 +143,7 @@ def main(
capture_output=True, capture_output=True,
check=True, check=True,
).stdout.split("\n") ).stdout.split("\n")
for name, members in expected_lists.items(): for name, props in expected_lists.items():
list_name = name + list_suffix list_name = name + list_suffix
list_manager = ListManager(mailman_bin, list_name, dry_run) list_manager = ListManager(mailman_bin, list_name, dry_run)
if list_name not in existing_lists: if list_name not in existing_lists:
@ -135,8 +154,13 @@ def main(
list_manager.newlist(urlhost, admin) list_manager.newlist(urlhost, admin)
print(f"Configuring/syncing {list_name}...") print(f"Configuring/syncing {list_name}...")
list_manager.config_list() list_manager.config_list(
list_manager.sync_members(members) props["real_name"],
props["moderator"],
props["subject_prefix"],
props["reply_to_address"],
)
list_manager.sync_members(props["members"])
def parse_arguments(): def parse_arguments():