Removing all moderatortors (and owners) from a list in one go
As there doesn't seem to be a "Disable list" REST call (not an "export list" REST call, I am trying to remove all members, moderators and owners, changing list description etc.
I managed to remove all members from a list in one go using https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/rest/docs/m..., but the same command, using /roster/moderator does not apply for moderators (now owners I guess).
To me it seems that each moderator has to be removed one by one, either:
- using REST https://docs.mailman3.org/projects/mailmanclient/en/latest/src/mailmanclient...
- or using the client https://lists.mailman3.org/archives/list/mailman-users@mailman3.org/thread/6...
- or using Python https://lists.mailman3.org/archives/list/mailman-users@mailman3.org/thread/V...
Isn't there an easier way? And why not like https://docs.mailman3.org/projects/mailman/en/latest/src/mailman/rest/docs/m... ?
/Henrik
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
participants (2)
-
Henrik Rasmussen
-
Mark Sapiro