From cf21ae13f1ba7f9ec5d92737f5fdf9b6b0def882 Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Mon, 9 Dec 2024 15:47:05 +0100 Subject: [PATCH] feat: Email Notification Settings Model --- app/Models/EmailNotificationSettings.php | 78 ++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 app/Models/EmailNotificationSettings.php diff --git a/app/Models/EmailNotificationSettings.php b/app/Models/EmailNotificationSettings.php new file mode 100644 index 000000000..640a44b7a --- /dev/null +++ b/app/Models/EmailNotificationSettings.php @@ -0,0 +1,78 @@ + 'boolean', + 'smtp_from_address' => 'encrypted', + 'smtp_recipients' => 'encrypted', + 'smtp_host' => 'encrypted', + 'smtp_port' => 'integer', + 'smtp_username' => 'encrypted', + 'smtp_password' => 'encrypted', + 'smtp_timeout' => 'integer', + + 'resend_enabled' => 'boolean', + 'resend_api_key' => 'encrypted', + + 'use_instance_email_settings' => 'boolean', + + 'deployment_success_email_notifications' => 'boolean', + 'deployment_failure_email_notifications' => 'boolean', + 'status_change_email_notifications' => 'boolean', + 'backup_success_email_notifications' => 'boolean', + 'backup_failure_email_notifications' => 'boolean', + 'scheduled_task_success_email_notifications' => 'boolean', + 'scheduled_task_failure_email_notifications' => 'boolean', + 'server_disk_usage_email_notifications' => 'boolean', + ]; + + public function team() + { + return $this->belongsTo(Team::class); + } + + public function isEnabled() + { + if (isCloud()) { + return true; + } + + return $this->smtp_enabled || $this->resend_enabled || $this->use_instance_email_settings; + } +}