Notifications fixes (#804)

* Emails not sending #795 #722

* Fix for news items not being sent; refactor some events; check for opt-in #722

* Formatting

* Remove extra parameter
This commit is contained in:
Nabeel S
2020-09-03 12:50:42 -04:00
committed by GitHub
parent 55fa01478d
commit e99c22b007
34 changed files with 179 additions and 54 deletions

View File

@@ -0,0 +1,41 @@
<?php
namespace App\Contracts;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Log;
class Notification extends \Illuminate\Notifications\Notification implements ShouldQueue
{
use Queueable;
public $channels = [];
public $requires_opt_in = false;
public function __construct()
{
// Look in the notifications.channels config and see where this particular
// notification can go. Map it to $channels
$klass = static::class;
$notif_config = config('notifications.channels', []);
if (!array_key_exists($klass, $notif_config)) {
Log::error('Notification type '.$klass.' missing from notifications config, defaulting to mail');
return;
}
$this->channels = $notif_config[$klass];
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*
* @return array
*/
public function via($notifiable)
{
return $this->channels;
}
}