From 2dc175be63428010cb1a4602de6cd8d2515951c3 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 13 Dec 2023 12:01:27 +0100 Subject: [PATCH] fix: null notify --- app/Jobs/ApplicationDeploymentJob.php | 4 ++-- app/Jobs/CheckLogDrainContainerJob.php | 6 +++--- app/Jobs/DatabaseBackupJob.php | 4 ++-- app/Jobs/ServerStatusJob.php | 2 +- app/Livewire/Notifications/DiscordSettings.php | 2 +- app/Livewire/Notifications/EmailSettings.php | 2 +- app/Livewire/Notifications/TelegramSettings.php | 2 +- app/Livewire/Settings/Email.php | 2 +- app/Models/Server.php | 4 ++-- app/Models/User.php | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 9e9725bd1..652fd2262 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -1341,10 +1341,10 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf"); } queue_next_deployment($this->application); if ($status === ApplicationDeploymentStatus::FINISHED->value) { - $this->application->environment->project->team->notify(new DeploymentSuccess($this->application, $this->deployment_uuid, $this->preview)); + $this->application->environment->project->team?->notify(new DeploymentSuccess($this->application, $this->deployment_uuid, $this->preview)); } if ($status === ApplicationDeploymentStatus::FAILED->value) { - $this->application->environment->project->team->notify(new DeploymentFailed($this->application, $this->deployment_uuid, $this->preview)); + $this->application->environment->project->team?->notify(new DeploymentFailed($this->application, $this->deployment_uuid, $this->preview)); } } diff --git a/app/Jobs/CheckLogDrainContainerJob.php b/app/Jobs/CheckLogDrainContainerJob.php index e66a0c08a..eb677265b 100644 --- a/app/Jobs/CheckLogDrainContainerJob.php +++ b/app/Jobs/CheckLogDrainContainerJob.php @@ -63,19 +63,19 @@ class CheckLogDrainContainerJob implements ShouldQueue, ShouldBeEncrypted Sleep::for(10)->seconds(); if ($this->healthcheck()) { if ($this->server->log_drain_notification_sent) { - $this->server->team->notify(new ContainerRestarted('Coolify Log Drainer', $this->server)); + $this->server->team?->notify(new ContainerRestarted('Coolify Log Drainer', $this->server)); $this->server->update(['log_drain_notification_sent' => false]); } return; } if (!$this->server->log_drain_notification_sent) { ray('Log drain container still unhealthy. Sending notification...'); - $this->server->team->notify(new ContainerStopped('Coolify Log Drainer', $this->server, null)); + $this->server->team?->notify(new ContainerStopped('Coolify Log Drainer', $this->server, null)); $this->server->update(['log_drain_notification_sent' => true]); } } else { if ($this->server->log_drain_notification_sent) { - $this->server->team->notify(new ContainerRestarted('Coolify Log Drainer', $this->server)); + $this->server->team?->notify(new ContainerRestarted('Coolify Log Drainer', $this->server)); $this->server->update(['log_drain_notification_sent' => false]); } } diff --git a/app/Jobs/DatabaseBackupJob.php b/app/Jobs/DatabaseBackupJob.php index 1ba855f4e..8a854128a 100644 --- a/app/Jobs/DatabaseBackupJob.php +++ b/app/Jobs/DatabaseBackupJob.php @@ -286,7 +286,7 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted if ($this->backup->save_s3) { $this->upload_to_s3(); } - $this->team->notify(new BackupSuccess($this->backup, $this->database)); + $this->team?->notify(new BackupSuccess($this->backup, $this->database)); $this->backup_log->update([ 'status' => 'success', 'message' => $this->backup_output, @@ -302,7 +302,7 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted ]); } send_internal_notification('DatabaseBackupJob failed with: ' . $e->getMessage()); - $this->team->notify(new BackupFailed($this->backup, $this->database, $this->backup_output)); + $this->team?->notify(new BackupFailed($this->backup, $this->database, $this->backup_output)); throw $e; } } diff --git a/app/Jobs/ServerStatusJob.php b/app/Jobs/ServerStatusJob.php index cfe61598f..9dacea95c 100644 --- a/app/Jobs/ServerStatusJob.php +++ b/app/Jobs/ServerStatusJob.php @@ -54,7 +54,7 @@ class ServerStatusJob implements ShouldQueue, ShouldBeEncrypted } else { $this->server->high_disk_usage_notification_sent = true; $this->server->save(); - $this->server->team->notify(new HighDiskUsage($this->server, $this->disk_usage, $this->server->settings->cleanup_after_percentage)); + $this->server->team?->notify(new HighDiskUsage($this->server, $this->disk_usage, $this->server->settings->cleanup_after_percentage)); } } else { DockerCleanupJob::dispatchSync($this->server); diff --git a/app/Livewire/Notifications/DiscordSettings.php b/app/Livewire/Notifications/DiscordSettings.php index cf8b116d4..f5f0d5591 100644 --- a/app/Livewire/Notifications/DiscordSettings.php +++ b/app/Livewire/Notifications/DiscordSettings.php @@ -52,7 +52,7 @@ class DiscordSettings extends Component public function sendTestNotification() { - $this->team->notify(new Test()); + $this->team?->notify(new Test()); $this->dispatch('success', 'Test notification sent.'); } } diff --git a/app/Livewire/Notifications/EmailSettings.php b/app/Livewire/Notifications/EmailSettings.php index f3b121851..cdbaef051 100644 --- a/app/Livewire/Notifications/EmailSettings.php +++ b/app/Livewire/Notifications/EmailSettings.php @@ -70,7 +70,7 @@ class EmailSettings extends Component } public function sendTestNotification() { - $this->team->notify(new Test($this->emails)); + $this->team?->notify(new Test($this->emails)); $this->dispatch('success', 'Test Email sent successfully.'); } public function instantSaveInstance() diff --git a/app/Livewire/Notifications/TelegramSettings.php b/app/Livewire/Notifications/TelegramSettings.php index 08f1be005..0f581a515 100644 --- a/app/Livewire/Notifications/TelegramSettings.php +++ b/app/Livewire/Notifications/TelegramSettings.php @@ -58,7 +58,7 @@ class TelegramSettings extends Component public function sendTestNotification() { - $this->team->notify(new Test()); + $this->team?->notify(new Test()); $this->dispatch('success', 'Test notification sent.'); } } diff --git a/app/Livewire/Settings/Email.php b/app/Livewire/Settings/Email.php index d005462a8..471c18e9c 100644 --- a/app/Livewire/Settings/Email.php +++ b/app/Livewire/Settings/Email.php @@ -106,7 +106,7 @@ class Email extends Component public function sendTestNotification() { - $this->settings->notify(new Test($this->emails)); + $this->settings?->notify(new Test($this->emails)); $this->dispatch('success', 'Test email sent.'); } } diff --git a/app/Models/Server.php b/app/Models/Server.php index 37a5ffe2a..790b30025 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -164,7 +164,7 @@ class Server extends BaseModel if ($serverUptimeCheckNumber >= $serverUptimeCheckNumberMax) { if ($this->unreachable_notification_sent === false) { ray('Server unreachable, sending notification...'); - $this->team->notify(new Unreachable($this)); + $this->team?->notify(new Unreachable($this)); $this->update(['unreachable_notification_sent' => true]); } $this->settings()->update([ @@ -401,7 +401,7 @@ class Server extends BaseModel } if (data_get($server, 'unreachable_notification_sent') === true) { - $server->team->notify(new Revived($server)); + $server->team?->notify(new Revived($server)); $server->update(['unreachable_notification_sent' => false]); } diff --git a/app/Models/User.php b/app/Models/User.php index ee963a523..c099eb2b6 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -98,7 +98,7 @@ class User extends Authenticatable implements SendsEmail } public function sendPasswordResetNotification($token): void { - $this->notify(new TransactionalEmailsResetPassword($token)); + $this?->notify(new TransactionalEmailsResetPassword($token)); } public function isAdmin()