fix: null notify

This commit is contained in:
Andras Bacsai 2023-12-13 12:01:27 +01:00
parent d93bf97919
commit 2dc175be63
10 changed files with 15 additions and 15 deletions

View File

@ -1341,10 +1341,10 @@ COPY ./nginx.conf /etc/nginx/conf.d/default.conf");
} }
queue_next_deployment($this->application); queue_next_deployment($this->application);
if ($status === ApplicationDeploymentStatus::FINISHED->value) { 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) { 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));
} }
} }

View File

@ -63,19 +63,19 @@ class CheckLogDrainContainerJob implements ShouldQueue, ShouldBeEncrypted
Sleep::for(10)->seconds(); Sleep::for(10)->seconds();
if ($this->healthcheck()) { if ($this->healthcheck()) {
if ($this->server->log_drain_notification_sent) { 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]); $this->server->update(['log_drain_notification_sent' => false]);
} }
return; return;
} }
if (!$this->server->log_drain_notification_sent) { if (!$this->server->log_drain_notification_sent) {
ray('Log drain container still unhealthy. Sending notification...'); 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]); $this->server->update(['log_drain_notification_sent' => true]);
} }
} else { } else {
if ($this->server->log_drain_notification_sent) { 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]); $this->server->update(['log_drain_notification_sent' => false]);
} }
} }

View File

@ -286,7 +286,7 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted
if ($this->backup->save_s3) { if ($this->backup->save_s3) {
$this->upload_to_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([ $this->backup_log->update([
'status' => 'success', 'status' => 'success',
'message' => $this->backup_output, 'message' => $this->backup_output,
@ -302,7 +302,7 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted
]); ]);
} }
send_internal_notification('DatabaseBackupJob failed with: ' . $e->getMessage()); 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; throw $e;
} }
} }

View File

@ -54,7 +54,7 @@ class ServerStatusJob implements ShouldQueue, ShouldBeEncrypted
} else { } else {
$this->server->high_disk_usage_notification_sent = true; $this->server->high_disk_usage_notification_sent = true;
$this->server->save(); $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 { } else {
DockerCleanupJob::dispatchSync($this->server); DockerCleanupJob::dispatchSync($this->server);

View File

@ -52,7 +52,7 @@ class DiscordSettings extends Component
public function sendTestNotification() public function sendTestNotification()
{ {
$this->team->notify(new Test()); $this->team?->notify(new Test());
$this->dispatch('success', 'Test notification sent.'); $this->dispatch('success', 'Test notification sent.');
} }
} }

View File

@ -70,7 +70,7 @@ class EmailSettings extends Component
} }
public function sendTestNotification() public function sendTestNotification()
{ {
$this->team->notify(new Test($this->emails)); $this->team?->notify(new Test($this->emails));
$this->dispatch('success', 'Test Email sent successfully.'); $this->dispatch('success', 'Test Email sent successfully.');
} }
public function instantSaveInstance() public function instantSaveInstance()

View File

@ -58,7 +58,7 @@ class TelegramSettings extends Component
public function sendTestNotification() public function sendTestNotification()
{ {
$this->team->notify(new Test()); $this->team?->notify(new Test());
$this->dispatch('success', 'Test notification sent.'); $this->dispatch('success', 'Test notification sent.');
} }
} }

View File

@ -106,7 +106,7 @@ class Email extends Component
public function sendTestNotification() public function sendTestNotification()
{ {
$this->settings->notify(new Test($this->emails)); $this->settings?->notify(new Test($this->emails));
$this->dispatch('success', 'Test email sent.'); $this->dispatch('success', 'Test email sent.');
} }
} }

View File

@ -164,7 +164,7 @@ class Server extends BaseModel
if ($serverUptimeCheckNumber >= $serverUptimeCheckNumberMax) { if ($serverUptimeCheckNumber >= $serverUptimeCheckNumberMax) {
if ($this->unreachable_notification_sent === false) { if ($this->unreachable_notification_sent === false) {
ray('Server unreachable, sending notification...'); ray('Server unreachable, sending notification...');
$this->team->notify(new Unreachable($this)); $this->team?->notify(new Unreachable($this));
$this->update(['unreachable_notification_sent' => true]); $this->update(['unreachable_notification_sent' => true]);
} }
$this->settings()->update([ $this->settings()->update([
@ -401,7 +401,7 @@ class Server extends BaseModel
} }
if (data_get($server, 'unreachable_notification_sent') === true) { 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]); $server->update(['unreachable_notification_sent' => false]);
} }

View File

@ -98,7 +98,7 @@ class User extends Authenticatable implements SendsEmail
} }
public function sendPasswordResetNotification($token): void public function sendPasswordResetNotification($token): void
{ {
$this->notify(new TransactionalEmailsResetPassword($token)); $this?->notify(new TransactionalEmailsResetPassword($token));
} }
public function isAdmin() public function isAdmin()