Override roster url

This commit is contained in:
root 2020-02-20 11:13:29 +01:00
parent 8d1f4f3fd8
commit 5c00e9c3ae
2 changed files with 10 additions and 9 deletions

View file

@ -13,14 +13,14 @@ mailman_url = config.get('Mailman', 'url')
mailman_username = config.get('Mailman', 'username')
mailman_password = config.get('Mailman', 'password')
domain = config.get('Mailman', 'domain')
roster_url = config.get('Mailman', 'roster_url', fallback='http://{mailman_url}/3.1/lists/{list_name}@{domain}/roster/member')
changed = int(open(filename).read())
if changed:
for section in config.sections():
if section not in ["Re2o", "Mailman"] and config.getboolean(section, 'activate'):
list_name = config.get(section, "list_name", fallback=section)
response1 = requests.get('http://{}/3.1/lists/{}@{}/roster/member'.format(mailman_url, list_name, domain), auth=(mailman_username, mailman_password))
response1 = requests.get(roster_url.format(mailman_url=mailman_url, list_namelist_name, domain=domain), auth=(mailman_username, mailman_password))
if "entries" in response1.json():
entries = response1.json()['entries']
old_emails = [entry['email'] for entry in entries]
@ -28,7 +28,7 @@ if changed:
emails_to_delete = [email for email in old_emails if email not in new_emails]
if emails_to_delete:
print("[..] Deleting non members from list {}".format(list_name))
response = requests.delete('http://{}/3.1/lists/{}@{}/roster/member'.format(mailman_url, list_name, domain), auth=(mailman_username,mailman_password), params={'emails': emails_to_delete})
response = requests.delete(roster_url.format(mailman_url=mailman_url, list_name=list_name, domain=domain), auth=(mailman_username,mailman_password), params={'emails': emails_to_delete})
print("[OK] Non members where deleted from list {}".format(list_name))
else:
print("[INFO] No member to delete for list {}".format(list_name))