mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-22 13:07:59 +01:00
#25: Made the SendNotifications job in line with the rest of the notification system's design.
This commit is contained in:
parent
ce5b060194
commit
fc4ae856f8
1 changed files with 10 additions and 22 deletions
|
@ -56,29 +56,17 @@ class SendNotifications extends Job implements SelfHandling, ShouldQueue
|
|||
{
|
||||
$this->beforeHandle();
|
||||
|
||||
// get list of users who are supposed to receive this notification
|
||||
$recipients = [User::find(1)];
|
||||
// This variable is set here instead of as a static class variable
|
||||
// to work around a Laravel bug - namely, the SerializesModels trait
|
||||
// tries (and fails) to serialize static fields.
|
||||
$drivers = [
|
||||
PonyfmDriver::class
|
||||
];
|
||||
|
||||
foreach ($recipients as $recipient) {
|
||||
// get drivers that this notification should be delivered through
|
||||
$drivers = $this->getDriversForNotification($recipient, $this->notificationType);
|
||||
|
||||
foreach ($drivers as $driver) {
|
||||
/** @var $driver AbstractDriver */
|
||||
call_user_func_array([$driver, $this->notificationType], $this->notificationData);
|
||||
}
|
||||
foreach ($drivers as $driver) {
|
||||
/** @var $driver AbstractDriver */
|
||||
$driver = new $driver;
|
||||
call_user_func_array([$driver, $this->notificationType], $this->notificationData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the drivers with which the given user has subscribed to the given
|
||||
* notification type.
|
||||
*
|
||||
* @param User $user
|
||||
* @param string $notificationType
|
||||
* @return AbstractDriver[]
|
||||
*/
|
||||
private function getDriversForNotification(User $user, string $notificationType) {
|
||||
return [new PonyfmDriver()];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue