fix: notifications
This commit is contained in:
parent
802ef03013
commit
8d8dcb1a3e
@ -14,7 +14,7 @@ class DiscordSettings extends Component
|
||||
'model.discord.webhook_url' => 'required|url',
|
||||
'model.discord_notifications.test' => 'nullable|boolean',
|
||||
'model.discord_notifications.deployments' => 'nullable|boolean',
|
||||
|
||||
'model.discord_notifications.stopped' => 'nullable|boolean',
|
||||
];
|
||||
protected $validationAttributes = [
|
||||
'model.discord.webhook_url' => 'Discord Webhook',
|
||||
|
@ -25,8 +25,7 @@ class EmailSettings extends Component
|
||||
'model.smtp.test_recipients' => 'nullable',
|
||||
'model.smtp_notifications.test' => 'nullable|boolean',
|
||||
'model.smtp_notifications.deployments' => 'nullable|boolean',
|
||||
'model.discord_notifications.test' => 'nullable|boolean',
|
||||
'model.discord_notifications.deployments' => 'nullable|boolean',
|
||||
'model.smtp_notifications.stopped' => 'nullable|boolean',
|
||||
];
|
||||
protected $validationAttributes = [
|
||||
'model.smtp.from_address' => 'From Address',
|
||||
|
@ -33,11 +33,9 @@ class ApplicationContainerStatusJob implements ShouldQueue, ShouldBeUnique
|
||||
}
|
||||
public function handle(): void
|
||||
{
|
||||
ray('checking status of ' . $this->container_name);
|
||||
try {
|
||||
$status = get_container_status(server: $this->application->destination->server, container_id: $this->container_name, throwError: false);
|
||||
ray($this->application->status, $status);
|
||||
if ($this->application->status === 'running' && $status !== 'running') {
|
||||
if ($this->application->status === 'running' && $status === 'stopped') {
|
||||
$this->application->environment->project->team->notify(new ApplicationStoppedNotification($this->application));
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ class ProxyCheckJob implements ShouldQueue
|
||||
if ($status === 'running') {
|
||||
continue;
|
||||
}
|
||||
// $server->team->notify(new ProxyStoppedNotification($server));
|
||||
resolve(StartProxy::class)($server);
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
|
@ -40,35 +40,28 @@ class ApplicationStoppedNotification extends Notification implements ShouldQueue
|
||||
$channels = [];
|
||||
$isEmailEnabled = data_get($notifiable, 'smtp.enabled');
|
||||
$isDiscordEnabled = data_get($notifiable, 'discord.enabled');
|
||||
$isSubscribedToEmailDeployments = data_get($notifiable, 'smtp_notifications.deployments');
|
||||
$isSubscribedToDiscordDeployments = data_get($notifiable, 'discord_notifications.deployments');
|
||||
$isSubscribedToEmailEvent = data_get($notifiable, 'smtp_notifications.stopped');
|
||||
$isSubscribedToDiscordEvent = data_get($notifiable, 'discord_notifications.stopped');
|
||||
|
||||
if ($isEmailEnabled && $isSubscribedToEmailDeployments) {
|
||||
if ($isEmailEnabled && $isSubscribedToEmailEvent) {
|
||||
$channels[] = EmailChannel::class;
|
||||
}
|
||||
if ($isDiscordEnabled && $isSubscribedToDiscordDeployments) {
|
||||
if ($isDiscordEnabled && $isSubscribedToDiscordEvent) {
|
||||
$channels[] = DiscordChannel::class;
|
||||
}
|
||||
return $channels;
|
||||
}
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
// $mail = new MailMessage();
|
||||
// $pull_request_id = data_get($this->preview, 'pull_request_id', 0);
|
||||
// $fqdn = $this->fqdn;
|
||||
// if ($pull_request_id === 0) {
|
||||
// $mail->subject("✅New version is deployed of {$this->application_name}");
|
||||
// } else {
|
||||
// $fqdn = $this->preview->fqdn;
|
||||
// $mail->subject("✅ Pull request #{$pull_request_id} of {$this->application_name} deployed successfully");
|
||||
// }
|
||||
// $mail->view('emails.application-deployed-successfully', [
|
||||
// 'name' => $this->application_name,
|
||||
// 'fqdn' => $fqdn,
|
||||
// 'deployment_url' => $this->deployment_url,
|
||||
// 'pull_request_id' => $pull_request_id,
|
||||
// ]);
|
||||
// return $mail;
|
||||
$mail = new MailMessage();
|
||||
$fqdn = $this->fqdn;
|
||||
$mail->subject("⛔ {$this->application_name} has been stopped");
|
||||
$mail->view('emails.application-stopped', [
|
||||
'name' => $this->application_name,
|
||||
'fqdn' => $fqdn,
|
||||
'application_url' => $this->application_url,
|
||||
]);
|
||||
return $mail;
|
||||
}
|
||||
|
||||
public function toDiscord(): string
|
||||
|
@ -45,13 +45,13 @@ class DeployedSuccessfullyNotification extends Notification implements ShouldQue
|
||||
$channels = [];
|
||||
$isEmailEnabled = data_get($notifiable, 'smtp.enabled');
|
||||
$isDiscordEnabled = data_get($notifiable, 'discord.enabled');
|
||||
$isSubscribedToEmailDeployments = data_get($notifiable, 'smtp_notifications.deployments');
|
||||
$isSubscribedToDiscordDeployments = data_get($notifiable, 'discord_notifications.deployments');
|
||||
$isSubscribedToEmailEvent = data_get($notifiable, 'smtp_notifications.deployments');
|
||||
$isSubscribedToDiscordEvent = data_get($notifiable, 'discord_notifications.deployments');
|
||||
|
||||
if ($isEmailEnabled && $isSubscribedToEmailDeployments) {
|
||||
if ($isEmailEnabled && $isSubscribedToEmailEvent) {
|
||||
$channels[] = EmailChannel::class;
|
||||
}
|
||||
if ($isDiscordEnabled && $isSubscribedToDiscordDeployments) {
|
||||
if ($isDiscordEnabled && $isSubscribedToDiscordEvent) {
|
||||
$channels[] = DiscordChannel::class;
|
||||
}
|
||||
return $channels;
|
||||
|
@ -46,13 +46,13 @@ class DeployedWithErrorNotification extends Notification implements ShouldQueue
|
||||
$channels = [];
|
||||
$isEmailEnabled = data_get($notifiable, 'smtp.enabled');
|
||||
$isDiscordEnabled = data_get($notifiable, 'discord.enabled');
|
||||
$isSubscribedToEmailDeployments = data_get($notifiable, 'smtp_notifications.deployments');
|
||||
$isSubscribedToDiscordDeployments = data_get($notifiable, 'discord_notifications.deployments');
|
||||
$isSubscribedToEmailEvent = data_get($notifiable, 'smtp_notifications.deployments');
|
||||
$isSubscribedToDiscordEvent = data_get($notifiable, 'discord_notifications.deployments');
|
||||
|
||||
if ($isEmailEnabled && $isSubscribedToEmailDeployments) {
|
||||
if ($isEmailEnabled && $isSubscribedToEmailEvent) {
|
||||
$channels[] = EmailChannel::class;
|
||||
}
|
||||
if ($isDiscordEnabled && $isSubscribedToDiscordDeployments) {
|
||||
if ($isDiscordEnabled && $isSubscribedToDiscordEvent) {
|
||||
$channels[] = DiscordChannel::class;
|
||||
}
|
||||
return $channels;
|
||||
|
2
resources/views/emails/application-stopped.blade.php
Normal file
2
resources/views/emails/application-stopped.blade.php
Normal file
@ -0,0 +1,2 @@
|
||||
{{ $name }} has been stopped.<br><br>
|
||||
<a target="_blank" href="{{ $application_url }}">View Application URL</a><br><br>
|
@ -26,8 +26,10 @@
|
||||
<x-forms.checkbox instantSave="saveModel" id="model.discord_notifications.test"
|
||||
label="Test Notifications" />
|
||||
@endif
|
||||
<h5 class="mt-4">Applications</h5>
|
||||
<x-forms.checkbox instantSave="saveModel" id="model.discord_notifications.deployments"
|
||||
label="New Deployments" />
|
||||
label="New Deployment" />
|
||||
<x-forms.checkbox instantSave="saveModel" id="model.discord_notifications.stopped" label="Stopped" />
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
@ -53,8 +53,10 @@
|
||||
<x-forms.checkbox instantSave="saveModel" id="model.smtp_notifications.test"
|
||||
label="Test Notifications" />
|
||||
@endif
|
||||
<h5 class="mt-4">Applications</h5>
|
||||
<x-forms.checkbox instantSave="saveModel" id="model.smtp_notifications.deployments"
|
||||
label="New Deployments" />
|
||||
label="New Deployment" />
|
||||
<x-forms.checkbox instantSave="saveModel" id="model.smtp_notifications.stopped" label="Stopped" />
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user