diff --git a/backend/app/Jobs/NotifyUsersManualModeOnJob.php b/backend/app/Jobs/NotifyUsersManualModeOnJob.php index e395ce8..beccf21 100644 --- a/backend/app/Jobs/NotifyUsersManualModeOnJob.php +++ b/backend/app/Jobs/NotifyUsersManualModeOnJob.php @@ -16,49 +16,49 @@ use DefStudio\Telegraph\Facades\Telegraph; class NotifyUsersManualModeOnJob implements ShouldQueue { - use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - /** - * Create a new job instance. - */ - public function __construct() - { - // + /** + * Create a new job instance. + */ + public function __construct() + { + // + } + + /** + * Execute the job. + */ + public function handle(): void + { + $users = TelegramBotLogins::join("users", "users.id", "=", "telegram_bot_logins.user") + ->select("users.id", "chat_id", "users.available") + ->where("users.availability_manual_mode", true) + ->whereNotNull("chat_id") + ->get(); + + foreach ($users as $user) { + //Get chat by id + $chat = Telegraph::chat($user["chat_id"]); + $state = $user["available"] ? "disponibile 🟢" : "non disponibile 🔴"; + $chat + ->message( + "⚠️ Attenzione! La tua disponibilità non segue la programmazione oraria." . + "\nAttualmente sei $state" . + "\nSe vuoi mantenere questa impostazione,\nignora questo messaggio." + ) + ->keyboard(Keyboard::make()->buttons([ + Button::make("🔧 Ripristina programmazione 🔧")->action('manual_mode_off')->param("user_id", $user["id"]), + Button::make("🗑 Elimina notifica 🗑")->action('delete_notification') + ])) + ->send(); } + } - /** - * Execute the job. - */ - public function handle(): void - { - $users = TelegramBotLogins::join("users", "users.id", "=", "telegram_bot_logins.user") - ->select("users.id", "chat_id", "users.available") - ->where("users.availability_manual_mode", true) - ->whereNotNull("chat_id") - ->get(); - - foreach ($users as $user) { - //Get chat by id - $chat = Telegraph::chat($user["chat_id"]); - $state = $user["available"] ? "disponibile 🟢" : "non disponibile 🔴"; - $chat - ->message( - "⚠️ Attenzione! La tua disponibilità non segue la programmazione oraria.". - "\nAttualmente sei $state". - "\nSe vuoi mantenere questa impostazione,\nignora questo messaggio." - ) - ->keyboard(Keyboard::make()->buttons([ - Button::make("🔧 Ripristina programmazione 🔧")->action('manual_mode_off')->param("user_id", $user["id"]), - Button::make("🗑 Elimina notifica 🗑")->action('delete_notification') - ])) - ->send(); - } - } - - public function failed(\Error|\TypeError $exception = null) - { - if (app()->bound('sentry')) { - app('sentry')->captureException($exception); - } + public function failed($exception = null) + { + if (app()->bound('sentry')) { + app('sentry')->captureException($exception); } + } } diff --git a/backend/app/Jobs/RemoveOldIpAddressesFromLogsJob.php b/backend/app/Jobs/RemoveOldIpAddressesFromLogsJob.php index 345483e..4ada917 100644 --- a/backend/app/Jobs/RemoveOldIpAddressesFromLogsJob.php +++ b/backend/app/Jobs/RemoveOldIpAddressesFromLogsJob.php @@ -24,4 +24,11 @@ class RemoveOldIpAddressesFromLogsJob implements ShouldQueue Log::where('created_at', '<', Carbon::now()->subWeeks(2)) ->update(['ip' => null]); } + + public function failed($exception = null) + { + if (app()->bound('sentry')) { + app('sentry')->captureException($exception); + } + } } diff --git a/backend/app/Jobs/ResetAvailabilityMinutesJob.php b/backend/app/Jobs/ResetAvailabilityMinutesJob.php index 1d9f42b..c9611f8 100644 --- a/backend/app/Jobs/ResetAvailabilityMinutesJob.php +++ b/backend/app/Jobs/ResetAvailabilityMinutesJob.php @@ -50,7 +50,7 @@ class ResetAvailabilityMinutesJob implements ShouldQueue } } - public function failed(\Error|\TypeError $exception = null) + public function failed($exception = null) { if (app()->bound('sentry')) { app('sentry')->captureException($exception); diff --git a/backend/app/Jobs/UpdateAvailabilityWithSchedulesJob.php b/backend/app/Jobs/UpdateAvailabilityWithSchedulesJob.php index 1db95d1..a1ff97d 100644 --- a/backend/app/Jobs/UpdateAvailabilityWithSchedulesJob.php +++ b/backend/app/Jobs/UpdateAvailabilityWithSchedulesJob.php @@ -95,7 +95,7 @@ class UpdateAvailabilityWithSchedulesJob implements ShouldQueue TelegramBot::sendTeamMessage($text); } - public function failed(\Error|\TypeError $exception = null) + public function failed($exception = null) { if (app()->bound('sentry') && !is_null($exception)) { app('sentry')->captureException($exception);