Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for giving notification mailing lists a name #2

Merged
merged 2 commits into from
Dec 5, 2020

Conversation

hispanic
Copy link
Owner

@hispanic hispanic commented Dec 5, 2020

Addresses issue eduardoboucas#127 - "Mailgun mailing lists - give each one a name"

I added support for passing in a new "parentName" option to the "entry" endpoint. You can set it to whatever value you prefer. For example:

  • options[parentName] = Post "Staticman is Awesome"
  • options[parentName] = Post staticman-is-awesome
  • options[parentName] = Comment 88688c70-12d1-11eb-b135-db5a5177adbc
  • options[parentName] = Comment 88688c70-12d1-11eb-b135-db5a5177adbc on Post staticman-is-awesome
  • options[parentName] = Blog "Mike's Tech Thoughts"

I chose "parentName" intentionally, as I believe @eduardoboucas originally added the "parent" option as "a unique identifier to the entry the user is subscribing to." More info: eduardoboucas#42 (comment)

When supplied, this value will be used to populate the "name" property of the created mailing list in Mailgun. In addition, supplying this option will also trigger the population of the "description" property for the mailing list. The description will be of the following form:

  • "Subscribers to: [parentName] ([repo-username]/[repo-name])

I have chosen to deliberately expose the relevant repository in the description, as that is factored into the creation of the mailing list ID.

If a "parentName" option is not passed, the mailing list will be created without a name or description, just as currently implemented.

As part of this change, I have modified the mailing list creation logic to set two other properties exposed by the Mailgun API:

  • Set "access_level" to "readonly". This will only allow authenticated users to post to the list. This is the Mailgun default, but I think it wise to explicitly set it in case the default changes.
  • Set "reply_preference" to "sender". Restricting replies to "sender" (as opposed to all members of the list) would seem to be the safest and most appropriate option for a list meant to receive notifications.

By setting the "reply_preference" property on the Mailgun mailing list to "sender", the "reply-to" of every email sent via the mailing list will be postmaster@[mailgun domain] instead of the "from" address (e.g., noreply@staticman.net). I defeat this by explicitly setting the "h:Reply-To" header (to be the same as the "from" address).

Michael Harry Scepaniak added 2 commits December 5, 2020 15:48
…one a name"

- If a "parentName" option is supplied, create the mailing list with a name and description.
- When creating a mailing list, explicitly set the "access_level" and "reply_preference" properties.
- In SubscriptionsManager, improve the error-handling.
- When sending a notification, explicitly set the "Reply-To" header.
- Update and add-to unit tests.
@hispanic hispanic closed this Dec 5, 2020
@hispanic hispanic reopened this Dec 5, 2020
@hispanic hispanic changed the base branch from master to dev December 5, 2020 21:06
@hispanic hispanic merged commit 46f93b5 into dev Dec 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant