mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-26 06:57:58 +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();
|
$this->beforeHandle();
|
||||||
|
|
||||||
// get list of users who are supposed to receive this notification
|
// This variable is set here instead of as a static class variable
|
||||||
$recipients = [User::find(1)];
|
// to work around a Laravel bug - namely, the SerializesModels trait
|
||||||
|
// tries (and fails) to serialize static fields.
|
||||||
foreach ($recipients as $recipient) {
|
$drivers = [
|
||||||
// get drivers that this notification should be delivered through
|
PonyfmDriver::class
|
||||||
$drivers = $this->getDriversForNotification($recipient, $this->notificationType);
|
];
|
||||||
|
|
||||||
foreach ($drivers as $driver) {
|
foreach ($drivers as $driver) {
|
||||||
/** @var $driver AbstractDriver */
|
/** @var $driver AbstractDriver */
|
||||||
|
$driver = new $driver;
|
||||||
call_user_func_array([$driver, $this->notificationType], $this->notificationData);
|
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