On 8/12/24 04:07, Henrik Rasmussen wrote:
Isn't there an easier way? And why not like https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/rest/docs/m... ?
The next release of Mailman core will include a mailman admins
command
for adding and removing list owners and moderators. You could back port
it simply by downloading and installing
https://gitlab.com/mailman/mailman/-/blob/master/src/mailman/commands/cli_ad...
The documentation is at https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/commands/do... but I suspect this isn't what you want anyway because it does owners and moderators separately and you need to provide their email addresses.
You could modify the script at https://lists.mailman3.org/archives/list/mailman-users@mailman3.org/message/... to remove all owners and moderators from a list. E.g.,
import os
import sys
from mailman.core import initialize
from mailman.database.transaction import transaction
from mailman.interfaces.listmanager import IListManager
from zope.component import getUtility
os.environ['MAILMAN_CONFIG_FILE'] = '/path/to/mailman.cfg'
initialize.initialize()
def delete_admins(list_id):
mlist = getUtility(IListManager).get(list_id)
if not mlist:
print(f'No such list {list_id}', file = sys.stderr)
sys.exit(1)
with transaction():
for admin in mlist.administrators.members:
admin.unsubscribe()
if __name__ == '__main__':
delete_admins(sys.argv[1])
Running this with an argument of the list-id or list posting address will remove all owners and moderators from a list.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan