Hi. I'm able to remove a list moderator through the REST interface:
dump_json('BASE_URL/3.1/lists/LIST_NAME/roster/moderator') ... find the correct member_id from the output dump_json('BASE_URL/3.1/members/MEMBER_ID', method='DELETE')
If I know the moderator's email address, is there a way to do this in a python function?
Thanks, Steve
On 7/20/24 1:27 PM, steve.bachinsky@tena-sda.org wrote:
If I know the moderator's email address, is there a way to do this in a python function?
Something like
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_moderator(list_id, email):
mlist = getUtility(IListManager).get_by_list_id(list_id)
if not mlist:
print(f'No such list {list_id}', file = sys.stderr)
sys.exit(1)
with transaction():
moderator = mlist.moderators.get_member(email)
if moderator:
moderator.unsubscribe()
else:
print(f'No such moderator {email}', file = sys.stderr)
sys.exit(1)
if __name__ == '__main__':
delete_moderator('list.example.comg', 'user@example.com')
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
Mark,
Thanks for your help, appreciate it! I should have asked previously, but if adding a moderator, how do I turn an email address into a "member" that can be subscribed as a moderator?
Thanks again, Steve
In the case of adding a moderator based on an email address, it is unclear whether there is already a user associated with that email address or not. So I tried to use the "moderator = user_manager.make_user(email)" interface. However, when trying to use "mlist.subscribe(moderator, MemberRole.moderator)", I get an error that User must have preferred address. And while I can set "moderator.preferred_address = email", I then get error that there is no attribute "verified_on", and I can't set that on the User.
This action is being performed by an administrator, and there is not a need to have the user confirm an email address. Any help on how to add a moderator based on an email address (which may or may not be associated with an existing User) would be appreciated.
On 7/21/24 13:39, steve.bachinsky@tena-sda.org wrote:
In the case of adding a moderator based on an email address, it is unclear whether there is already a user associated with that email address or not. So I tried to use the "moderator = user_manager.make_user(email)" interface. However, when trying to use "mlist.subscribe(moderator, MemberRole.moderator)", I get an error that User must have preferred address. And while I can set "moderator.preferred_address = email", I then get error that there is no attribute "verified_on", and I can't set that on the User.
moderator.preferred_address needs to be set to an Address object, not an email. I.e.
moderator.preferred_address = user_manager.get_address(email)
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
participants (2)
-
Mark Sapiro
-
steve.bachinsky@tena-sda.org