getting all registered users and their lists
hi,
TL;DR is there a scriptable way to get all users that have registered in my mailman3 (3.2.1) instance and which lists they are subscribed to (if any)?
longer version:
we are running Mailman3-3.2.1 as shipped with Debian/buster (i know that this is not the newest version; at this point, please refrain from asking me to upgrade my Debian installation or even to switch to a venv installation of mailman3: i'll eventually do that but right now i've gt a problem to solve :-))
a few weeks ago, we invited a number of people to join a new mailinglist via a link that points to the subscription interface of the list, e.g. <https://lists.example.com/postorious/lists/foo.lists.example.com/>
now of course a number of these people had problems with the webinterface, confusing the big "Subscribe" button at the bottom of the page with the much smaller "Sign Up" button in the header (in German this button reads "Registrieren" which has a meaning that is pretty similar to "Subscribe"). people that "Signed up" typically do not understand that they have not been subscribed to any mailinglist (yet), wondering why they do not get any emails. at least this is what we suspect from feedback we got.
to fix the situtation, i would like to check which users had this problem (and eventually contact them to explain the problem).
for this i would like to get a listing of all users that are not subscribed to any mailinglist. i would also like to query, when a given user has signed up (so i can reduce the number of false positives)
how would i do that? ideally i would rather not work on an SQL level.
gfdmfas IOhannes
On 1/26/22 00:16, IOhannes m zmoelnig wrote:
hi,
TL;DR is there a scriptable way to get all users that have registered in my mailman3 (3.2.1) instance and which lists they are subscribed to (if any)?
It's in Postorius >= 1.3.6
longer version:
we are running Mailman3-3.2.1 as shipped with Debian/buster (i know that this is not the newest version; at this point, please refrain from asking me to upgrade my Debian installation or even to switch to a venv installation of mailman3: i'll eventually do that but right now i've gt a problem to solve :-))
See above.
...
for this i would like to get a listing of all users that are not subscribed to any mailinglist. i would also like to query, when a given user has signed up (so i can reduce the number of false positives)
how would i do that? ideally i would rather not work on an SQL level.
You can do this in mailman shell
$ bin/mailman shell
Welcome to the GNU Mailman shell
Use commit() to commit changes.
Use abort() to discard changes since the last commit.
Exit with ctrl+D does an implicit commit() but exit() does not.
>>> um = getUtility(IUserManager)
>>> for usr in um.users:
... if len(list(usr.memberships.members)) > 0:
... continue
... adr = usr.addresses[0]
... print(f'Name: {adr.display_name}, Email: {adr.email}, Created:
{usr.created_on}')
...
Or to skip older ones
>>> from datetime import datetime
>>> um = getUtility(IUserManager)
>>> for usr in um.users:
... if len(list(usr.memberships.members)) > 0:
... continue
... if usr.created_on < datetime(2022, 1, 1):
... continue
... adr = usr.addresses[0]
... print(f'Name: {adr.display_name}, Email: {adr.email}, Created:
{usr.created_on}')
...
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
On 1/26/22 17:19, Mark Sapiro wrote:
On 1/26/22 00:16, IOhannes m zmoelnig wrote:
You can do this in mailman shell[...]> ```
from datetime import datetime um = getUtility(IUserManager) for usr in um.users: ... if len(list(usr.memberships.members)) > 0: ... continue ... if usr.created_on < datetime(2022, 1, 1): ... continue ... adr = usr.addresses[0] ... print(f'Name: {adr.display_name}, Email: {adr.email}, Created: {usr.created_on}') ...
perfect. that did the trick, thanks a lot.
is there a scriptable way to get all users that have registered in my mailman3 (3.2.1) instance and which lists they are subscribed to (if any)?
It's in Postorius >= 1.3.6
i'm not entirely sure how this relates to the above (working) snippet.
is it, that with postorious>=1.3.6 i would be able to perform that task from the webinterface, rather than having to resort to 'mailman shell'?
in any case, this might be related:
before i received your email with the 'mailman shell' snippet, i scraped
some bits of my django knowledge and visited
<https://lists.example.com/admin> (the django admin interface), and
noticed the list of users there.
so i scraped that page for users (assuming that this was the list of
registered users).
then i get myself a list of all subscribers in my instance, using a
crude mailman lists | grep "@" | while read l; do mailman members "${l}"; done | sort -u
.
finally i calculated the difference between the two sets.
interestingly the results are quite different from the ones i got from your script: both sets contain users that are not in the other set. how come?
gfmdras IOhannes
On 1/27/22 00:06, IOhannes m zmoelnig wrote:
On 1/26/22 17:19, Mark Sapiro wrote:
On 1/26/22 00:16, IOhannes m zmoelnig wrote:
is there a scriptable way to get all users that have registered in my mailman3 (3.2.1) instance and which lists they are subscribed to (if any)?
It's in Postorius >= 1.3.6
i'm not entirely sure how this relates to the above (working) snippet.
is it, that with postorious>=1.3.6 i would be able to perform that task from the webinterface, rather than having to resort to 'mailman shell'?
Not really. In Postorius 1.3.6 there is a Users
view that will display
users and their create date and it is ordered by create date. Then each
user's entry has a Manage
button which goes to a page which among
other things, lists their subsubscriptions.
So, you could find the users of interest via this interface, but unless you developed a screen scraping script, it would be a multi-step manual process.
in any case, this might be related: before i received your email with the 'mailman shell' snippet, i scraped some bits of my django knowledge and visited <https://lists.example.com/admin> (the django admin interface), and noticed the list of users there. so i scraped that page for users (assuming that this was the list of registered users). then i get myself a list of all subscribers in my instance, using a crude
mailman lists | grep "@" | while read l; do mailman members "${l}"; done | sort -u
. finally i calculated the difference between the two sets.interestingly the results are quite different from the ones i got from your script: both sets contain users that are not in the other set. how come?
My script deals with Mailman users who may or may not be Django users. They won't be if they never signed up on the web UI. On the other hand, anyone can go to the web UI and sign up and become a Django user even if they never join any list and become a Mailman user.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
participants (2)
-
IOhannes m zmoelnig
-
Mark Sapiro