MESH-Research / Pilcrow

A web application for Collaborative Community Review
https://pilcrow.meshresearch.dev/
GNU Lesser General Public License v3.0
4 stars 3 forks source link

Send Users Email Notifications #698

Closed gmeben closed 2 years ago

gmeben commented 2 years ago

Problem/Why

Currently, there are no communication channels defined for sending notifications to users via email.

Goal/What

Figure out how to send notifications to users in the following ways:

Solution/How

Research how to setup notifications with email. https://laravel.com/docs/8.x/notifications

To Do / Acceptance Criteria

gmeben commented 2 years ago

Since yesterday I've discovered a way to send email notifications that's far simpler than the method I previously discovered that involves using the EventServiceProvider with events ands listeners.

Here's how it will work with each new notification we will create:

  1. Add 'mail' to the array within the via() method of the pertinent notification class
  2. Configure the toMail() method within this class as necessary
  3. Inside the GraphQL mutation class in Laravel, notify users using either the Notify facade or the $user->notify() method
gmeben commented 2 years ago

After discussing with the team during team time yesterday, we've decided that utilizing the event/listener pattern would be better suited for notifications as the improved modularity of events and listeners will afford better code organization. With the other pattern, notification logic (content and recipients) can muddy mutation classes or other files that aren't primarily concerned with notifications. Also, we can still leverage the toMail() and via() methods in notification classes with this pattern.