Files
coolify/app/Models/EmailNotificationSettings.php
22a8c09dd6 Next (#12202)
Co-authored-by: Aditya Tripathi <aditya@climactic.co>
Co-authored-by: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: rosslh <ross@rosshill.ca>
Co-authored-by: Abdulfetah Suudi <suudiabdulfetah@gmail.com>
Co-authored-by: Dharmveer <51308779+dharmveer97@users.noreply.github.com>
Co-authored-by: Maxwell <136101+mxswd@users.noreply.github.com>
2026-10-19 10:07:23 +02:00

113 lines
3.3 KiB
PHP

<?php
namespace App\Models;
use App\Traits\TracksDeliveryFailures;
use Illuminate\Database\Eloquent\Model;
class EmailNotificationSettings extends Model
{
use TracksDeliveryFailures;
public $timestamps = false;
protected $fillable = [
'team_id',
'smtp_enabled',
'smtp_from_address',
'smtp_from_name',
'smtp_recipients',
'smtp_host',
'smtp_port',
'smtp_encryption',
'smtp_username',
'smtp_password',
'smtp_timeout',
'smtp_ehlo_domain',
'resend_enabled',
'resend_api_key',
'use_instance_email_settings',
'deployment_success_email_notifications',
'deployment_failure_email_notifications',
'deployment_commit_details_email_notifications',
'status_change_email_notifications',
'restart_limit_reached_email_notifications',
'backup_success_email_notifications',
'backup_failure_email_notifications',
'scheduled_task_success_email_notifications',
'scheduled_task_failure_email_notifications',
'docker_cleanup_success_email_notifications',
'docker_cleanup_failure_email_notifications',
'server_disk_usage_email_notifications',
'server_reachable_email_notifications',
'server_unreachable_email_notifications',
'server_patch_email_notifications',
'traefik_outdated_email_notifications',
];
protected $hidden = [
'smtp_from_address',
'smtp_from_name',
'smtp_recipients',
'smtp_host',
'smtp_username',
'smtp_password',
'resend_api_key',
];
protected $casts = [
'smtp_enabled' => 'boolean',
'smtp_from_address' => 'encrypted',
'smtp_from_name' => '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',
'deployment_commit_details_email_notifications' => 'boolean',
'status_change_email_notifications' => 'boolean',
'restart_limit_reached_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',
'server_patch_email_notifications' => 'boolean',
'traefik_outdated_email_notifications' => 'boolean',
];
public function team()
{
return $this->belongsTo(Team::class);
}
public function isEnabled()
{
return $this->smtp_enabled || $this->resend_enabled || $this->use_instance_email_settings;
}
public function notificationChannelName(): string
{
return 'Email';
}
protected function disableNotificationChannel(): void
{
$this->smtp_enabled = false;
$this->resend_enabled = false;
}
}