#25: Made the SendNotifications job in line with the rest of the notification system's design.

This commit is contained in:
Peter Deltchev 2016-05-27 22:21:35 -07:00
parent ce5b060194
commit fc4ae856f8

View file

@ -55,30 +55,18 @@ class SendNotifications extends Job implements SelfHandling, ShouldQueue
public function handle() public function handle()
{ {
$this->beforeHandle(); $this->beforeHandle();
// get list of users who are supposed to receive this notification
$recipients = [User::find(1)];
foreach ($recipients as $recipient) { // This variable is set here instead of as a static class variable
// get drivers that this notification should be delivered through // to work around a Laravel bug - namely, the SerializesModels trait
$drivers = $this->getDriversForNotification($recipient, $this->notificationType); // tries (and fails) to serialize static fields.
$drivers = [
PonyfmDriver::class
];
foreach ($drivers as $driver) { foreach ($drivers as $driver) {
/** @var $driver AbstractDriver */ /** @var $driver AbstractDriver */
call_user_func_array([$driver, $this->notificationType], $this->notificationData); $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()];
}
} }