REST API Question: possible to change user preferred email?
Hi, We are in need of being able to change a user's email address via the REST API. After looking through the documentation and code, I can't see a way to do this in a simple way.
Although the documentation seems to show that if a user changes their preferred address, it will track throughout all their subscriptions.
See: https://gitlab.com/mailman/mailman/blob/master/src/mailman/rest/docs/members... "When Gwen changes her preferred address, her subscription automatically tracks the new address."
The only way I can see to do this via the REST API would be to do the following long winded way:
*1. Create a new address:* POST to http://<api_url>/3.1/users/<$OldEmail>/addresses $postData: {email = "$NewEmail"}
*2. Verify the new address:* POST to http://<api_url>/3.1/addresses/<$NewEmail>/verify $postData: { }
*3. Get all the memberships for the old email address* $memberships = GET to http://<api_url>/3.1/addresses/<$OldEmail>/memberships
*4. Change users email for each membership individually* foreach ($membership in $memberships) { PATCH to http://<api_url>/3.1/members/<$membership.member_id> $pathData: { address = $NewEmail } }
*5. Delete Old Address* DELETE to http://<api_url>/3.1/addresses/<$OldEmail>
Am I missing something (as in there is a way to do a single PATCH request somewhere)? Or is this the only way to update someone's email address with these 5 steps?
Thanks, Nathan Dixon
On Fri, Mar 15, 2019, at 10:59 AM, Nathan Dixon wrote:
Hi, We are in need of being able to change a user's email address via the REST API. After looking through the documentation and code, I can't see a way to do this in a simple way.
Although the documentation seems to show that if a user changes their preferred address, it will track throughout all their subscriptions.
It depends on how are you actually using Mailman. Postorius today subscribes people using their addresses, so the method you mentioned below is the correct way to change addresses.
If you think you are going to do this more frequently, you could subscribe users with their user_ids and then when you need to change their memberships, you just update their preferred_address.
See 1 here for how to join a mailing list using user_ids. Note that this isn't available today using Postorius (our Web UI), but I'd be happy to work with you if you want to contribute it.
See: https://gitlab.com/mailman/mailman/blob/master/src/mailman/rest/docs/members... "When Gwen changes her preferred address, her subscription automatically tracks the new address."
The only way I can see to do this via the REST API would be to do the following long winded way:
*1. Create a new address:* POST to http://<api_url>/3.1/users/<$OldEmail>/addresses $postData: {email = "$NewEmail"}
*2. Verify the new address:* POST to http://<api_url>/3.1/addresses/<$NewEmail>/verify $postData: { }
*3. Get all the memberships for the old email address* $memberships = GET to http://<api_url>/3.1/addresses/<$OldEmail>/memberships
*4. Change users email for each membership individually* foreach ($membership in $memberships) { PATCH to http://<api_url>/3.1/members/<$membership.member_id> $pathData: { address = $NewEmail } }
*5. Delete Old Address* DELETE to http://<api_url>/3.1/addresses/<$OldEmail>
Am I missing something (as in there is a way to do a single PATCH request somewhere)? Or is this the only way to update someone's email address with these 5 steps?
Thanks, Nathan Dixon
Mailman-users mailing list -- mailman-users@mailman3.org To unsubscribe send an email to mailman-users-leave@mailman3.org https://lists.mailman3.org/mailman3/lists/mailman-users.mailman3.org/
-- thanks, Abhilash Raj (maxking)
participants (2)
-
Abhilash Raj
-
Nathan Dixon