Bulk adding auto approve email domains

Continuing the discussion from Formalized assignment and possible logging of pending applications

Is the value for  auto approve email domains  a space‑separated string? Or comma‑separated or newline‑separated? TIA, R

In the UI, you add them one by one using the :heavy_plus_sign: button (and then confirming with the green tick)

Many thanks @JammyDodger. We were thinking of being a bit more automated. We planned to export our current list of emails, then extract those that matched the hipo list of university domains, and then import that new list into discourse under the auto approve email domains key. Using python and pandas for the numercal processing. I guess that route is not supported? Or do we, or can we, have programmatic access? (PS: with reference to your screenshot, gmail.com is that last domain name we would dream of automatically approving.)

Oh, and can we use wildcards like: *.tu‑berlin.de to account for departmental information being included, say maths.tu‑berlin.de.

1 Like

I had a feeling I was being far too simplistic. :slight_smile: I think this would benefit from splitting into a new #support topic to get some more knowledgeable eyes on it. :+1:

This I can appreciate. :slight_smile: Don’t worry though, it was a screenshot of a mockup on my test site, not the settings here on Meta. :slight_smile:

1 Like

Sadly, I believe this is not possible. I made a feature request mentioning this:

My main proposal was probably not what you’d want (it would mean if you added tu-berlin.de it would include maths.tu-berlin.de and every other department).

That is exactly the behavior I was seeking.

1 Like

If you have access to the Rails console, then you can set allowed email domains to an a pipe-delimited string with arbitrarily many hostnames, so that sounds workable.

Not sure why you would need numerical processing though; this can be done with standard UNIX tooling.

This gives you the list of domains from the Hipo list:

curl -L 'https://github.com/Hipo/university-domains-list/blob/master/world_universities_and_domains.json?raw=true' |
  jq '.[].domains' |
  jq -r add |
  sort -u

If you saved that as domains.txt, and assuming you have a file with email addresses named emails.txt, you could get the subset of domains to allowlist with this:

grep -if domains.txt emails.txt |
  cut -d @ -f 2 |
  sort -u

That is, even if the domain list contains just tusculum.edu, an email like some.student@mail.tusculum.edu would yield mail.tusculum.edu which is the hostname you actually want to allowlist, as opposed to the apex.

Then it’s just a matter of setting a pipe delimited string containing these domains. Does that work for you?

1 Like

Thanks @leonardo. I will need to ask my discourse hosting provider if I can access the Ruby on Rails console (I tend to suspect not?). But will submit a question tomorrow.

I am comfortable with the bash shell utilities you mention (I started on SCO UnixWare circa 1997 before migrating to Linux). One reason for adopting python is that future admins of our forum are more likely to be knowledgeable about python.

1 Like

Perfect; Python should make it equally easy.

Failing that, you can use the API (with an admin account) to PUT /admin/site_settings/allowed_email_domains with a form encoded payload like this:

allowed_email_domains=zuyd.nl%7Czzgc.edu.cn%7Czzut.edu.cn

No, you cannot, but you can always use the API (as Leonardo suggested) or simply open a ticket with the command you want us to run for you. We’ll even send you back the output :wink:

3 Likes

@RGJ many thanks. One other thought, probably completely without merit. But being able to upload an overarching database, such as the hipo list, to a discourse instance and have discourse do this kind of screening and processing would, from a users perspective, be ideal. :sloth: