Benutzer über einen API-Aufruf von allen E-Mails abmelden?

The site I maintain uses Discourse via SSO. When a user of my site unsubscribes from site generated emails, I would also like to unsubscribe the user from Discourse emails. It should be possible to determine what is required by looking at the API calls that are made when user email settings are changed via the UI, but I was wondering if there is an easier way?

1 „Gefällt mir“

Will it always be the case that they don’t want to see site emails and community emails?

If the possibility exists that they will want to opt out of one and not both why not simply link to a page where they can manage their email preferences for discourse?

3 „Gefällt mir“

Yes. Management has told me to unsubscribe users from discourse email when the user unsubs from site emails.

1 „Gefällt mir“

For anyone interested in a follow up:
My need was met by following the reverse engineering guide. It was a fairly straight forward process to collect the contents of the PUT payload.

in Ruby, the payload I ended up with is:
payload = {mailing_list_mode: false, mailing_list_mode_frequency: 1, email_digests: false, email_in_reply_to: false, email_messages_level: 2, email_level: 2, email_previous_replies: 2 }

the ‘mailing_list_mode_frequency’ can probably be excluded since mailing_list_mode is false.
The payload is then PUT to https://DISCOURSEHOST/u/USERNAME.json?api_key=DISCOURSE_SYSTEM_API_KEY&api_username=system

7 „Gefällt mir“

Ich habe dieselbe Logik implementiert, aber die Werte werden in den Benutzer-E-Mail-Einstellungen der Website nicht angezeigt.

Beachten Sie, dass die Methode, api_key und api_username über Abfrageparameter zu übergeben, nun veraltet ist. Sie sollten stattdessen die Header Api-Key und Api-Username verwenden heutzutage.

1 „Gefällt mir“