diff --git a/src/Notifications/RefreshTokenDeletedNotification.php b/src/Notifications/RefreshTokenDeletedNotification.php index f1bdbf4..a47836c 100644 --- a/src/Notifications/RefreshTokenDeletedNotification.php +++ b/src/Notifications/RefreshTokenDeletedNotification.php @@ -12,7 +12,6 @@ use Herpaderpaldent\Seat\SeatNotifications\Channels\Discord\DiscordMessage; use Herpaderpaldent\Seat\SeatNotifications\Channels\Slack\SlackChannel; use Herpaderpaldent\Seat\SeatNotifications\Channels\Slack\SlackMessage; -use Illuminate\Support\Facades\Redis; use Seat\Eveapi\Models\Corporation\CorporationInfo; use Seat\Eveapi\Models\RefreshToken; @@ -49,39 +48,28 @@ public function __construct(RefreshToken $refresh_token) */ public function via($notifiable) { - Redis::funnel('seatnotification:channel_id' . $notifiable->channel_id)->limit(1)->then(function () use ($notifiable) { - switch($notifiable->via) { - case 'discord': - $this->tags = [ - 'refresh_token', - 'discord', - $notifiable->type === 'private' ? $notifiable->recipient() : 'channel', - ]; - - return [DiscordChannel::class]; - break; - case 'slack': - $this->tags = [ - 'refresh_token', - 'slack', - $notifiable->type === 'private' ? $notifiable->recipient() : 'channel', - ]; - - return [SlackChannel::class]; - break; - default: - return ['']; - } - }, function () use ($notifiable) { - - logger()->warning(' A notification on ' . $notifiable->via . - ' for channel ' . $notifiable->channel_id . - ' has already been dispateched. Removing the job from the queue'); - - $this->delete(); - }); - - return ['']; + switch($notifiable->via) { + case 'discord': + $this->tags = [ + 'refresh_token', + 'discord', + $notifiable->type === 'private' ? $notifiable->recipient() : 'channel', + ]; + + return [DiscordChannel::class]; + break; + case 'slack': + $this->tags = [ + 'refresh_token', + 'slack', + $notifiable->type === 'private' ? $notifiable->recipient() : 'channel', + ]; + + return [SlackChannel::class]; + break; + default: + return ['']; + } } public function toDiscord($notifiable) diff --git a/src/Observers/RefreshTokenObserver.php b/src/Observers/RefreshTokenObserver.php index 55a0a4d..c6d4875 100644 --- a/src/Observers/RefreshTokenObserver.php +++ b/src/Observers/RefreshTokenObserver.php @@ -10,7 +10,6 @@ use Herpaderpaldent\Seat\SeatNotifications\Models\RefreshTokenNotification; use Herpaderpaldent\Seat\SeatNotifications\Notifications\RefreshTokenDeletedNotification; -use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Redis; use Seat\Eveapi\Models\RefreshToken; @@ -20,7 +19,7 @@ class RefreshTokenObserver public function deleting(RefreshToken $refresh_token) { Redis::funnel('soft_delete:refresh_token_' . $refresh_token->user->name)->limit(1)->then(function () use ($refresh_token) { - Log::info('SoftDelete detected of ' . $refresh_token->user->name); + logger()->info('SoftDelete detected of ' . $refresh_token->user->name); $receipients = RefreshTokenNotification::all() ->filter(function ($recepient) { @@ -29,20 +28,27 @@ public function deleting(RefreshToken $refresh_token) Notification::send($receipients, (new RefreshTokenDeletedNotification($refresh_token))); }, function () use ($refresh_token) { - Log::info('A Soft-Delete job is already running for ' . $refresh_token->user->name); + logger()->info('A Soft-Delete job is already running for ' . $refresh_token->user->name); }); } public function test() { - $receipients = RefreshTokenNotification::all() - ->filter(function ($recepient) { - return $recepient->shouldReceive(); - }); $refresh_token = RefreshToken::find(95725047); - Notification::send($receipients, (new RefreshTokenDeletedNotification($refresh_token))); + Redis::funnel('soft_delete:refresh_token_' . $refresh_token->user->name)->limit(1)->then(function () use ($refresh_token) { + logger()->info('SoftDelete detected of ' . $refresh_token->user->name); + + $receipients = RefreshTokenNotification::all() + ->filter(function ($recepient) { + return $recepient->shouldReceive(); + }); + + Notification::send($receipients, (new RefreshTokenDeletedNotification($refresh_token))); + }, function () use ($refresh_token) { + logger()->info('A Soft-Delete job is already running for ' . $refresh_token->user->name); + }); } } diff --git a/src/config/seatnotifications.config.php b/src/config/seatnotifications.config.php index 6d36c79..e48aef6 100644 --- a/src/config/seatnotifications.config.php +++ b/src/config/seatnotifications.config.php @@ -6,5 +6,5 @@ * Time: 10:24. */ return [ - 'version' => '1.0.2', + 'version' => '1.0.3', ];