fix: migrate db schema for smtp + discord

This commit is contained in:
Andras Bacsai
2023-07-27 21:26:15 +02:00
parent d0a85713d2
commit 9c393ff6bc
21 changed files with 382 additions and 238 deletions

View File

@@ -24,8 +24,8 @@ class EmailChannel
[],
fn (Message $message) => $message
->from(
data_get($notifiable, 'smtp.from_address'),
data_get($notifiable, 'smtp.from_name'),
data_get($notifiable, 'smtp_from_address'),
data_get($notifiable, 'smtp_from_name'),
)
->bcc($bcc)
->subject($mailMessage->subject)
@@ -35,19 +35,19 @@ class EmailChannel
private function bootConfigs($notifiable): void
{
$password = data_get($notifiable, 'smtp.password');
$password = data_get($notifiable, 'smtp_password');
if ($password) $password = decrypt($password);
config()->set('mail.default', 'smtp');
config()->set('mail.mailers.smtp', [
"transport" => "smtp",
"host" => data_get($notifiable, 'smtp.host'),
"port" => data_get($notifiable, 'smtp.port'),
"encryption" => data_get($notifiable, 'smtp.encryption'),
"username" => data_get($notifiable, 'smtp.username'),
"host" => data_get($notifiable, 'smtp_host'),
"port" => data_get($notifiable, 'smtp_port'),
"encryption" => data_get($notifiable, 'smtp_encryption'),
"username" => data_get($notifiable, 'smtp_username'),
"password" => $password,
"timeout" => data_get($notifiable, 'smtp.timeout'),
"timeout" => data_get($notifiable, 'smtp_timeout'),
"local_domain" => null,
]);
}
}
}

View File

@@ -13,7 +13,7 @@ class TransactionalEmailChannel
public function send(User $notifiable, Notification $notification): void
{
$settings = InstanceSettings::get();
if (data_get($settings, 'smtp.enabled') !== true) {
if (data_get($settings, 'smtp_enabled') !== true) {
return;
}
$email = $notifiable->email;
@@ -27,8 +27,8 @@ class TransactionalEmailChannel
[],
fn (Message $message) => $message
->from(
data_get($settings, 'smtp.from_address'),
data_get($settings, 'smtp.from_name')
data_get($settings, 'smtp_from_address'),
data_get($settings, 'smtp_from_name')
)
->to($email)
->subject($mailMessage->subject)
@@ -40,4 +40,4 @@ class TransactionalEmailChannel
{
set_transanctional_email_settings();
}
}
}

View File

@@ -38,10 +38,10 @@ class ApplicationStoppedNotification extends Notification implements ShouldQueue
public function via(object $notifiable): array
{
$channels = [];
$isEmailEnabled = data_get($notifiable, 'smtp.enabled');
$isDiscordEnabled = data_get($notifiable, 'discord.enabled');
$isSubscribedToEmailEvent = data_get($notifiable, 'smtp_notifications.status_changes');
$isSubscribedToDiscordEvent = data_get($notifiable, 'discord_notifications.status_changes');
$isEmailEnabled = data_get($notifiable, 'smtp_enabled');
$isDiscordEnabled = data_get($notifiable, 'discord_enabled');
$isSubscribedToEmailEvent = data_get($notifiable, 'smtp_notifications_status_changes');
$isSubscribedToDiscordEvent = data_get($notifiable, 'discord_notifications_status_changes');
if ($isEmailEnabled && $isSubscribedToEmailEvent) {
$channels[] = EmailChannel::class;
@@ -67,7 +67,7 @@ class ApplicationStoppedNotification extends Notification implements ShouldQueue
public function toDiscord(): string
{
$message = '⛔ ' . $this->application_name . ' has been stopped.
';
$message .= '[Application URL](' . $this->application_url . ')';
return $message;

View File

@@ -43,10 +43,10 @@ class DeployedSuccessfullyNotification extends Notification implements ShouldQue
public function via(object $notifiable): array
{
$channels = [];
$isEmailEnabled = data_get($notifiable, 'smtp.enabled');
$isDiscordEnabled = data_get($notifiable, 'discord.enabled');
$isSubscribedToEmailEvent = data_get($notifiable, 'smtp_notifications.deployments');
$isSubscribedToDiscordEvent = data_get($notifiable, 'discord_notifications.deployments');
$isEmailEnabled = data_get($notifiable, 'smtp_enabled');
$isDiscordEnabled = data_get($notifiable, 'discord_enabled');
$isSubscribedToEmailEvent = data_get($notifiable, 'smtp_notifications_deployments');
$isSubscribedToDiscordEvent = data_get($notifiable, 'discord_notifications_deployments');
if ($isEmailEnabled && $isSubscribedToEmailEvent) {
$channels[] = EmailChannel::class;
@@ -79,16 +79,16 @@ class DeployedSuccessfullyNotification extends Notification implements ShouldQue
public function toDiscord(): string
{
if ($this->preview) {
$message = '✅ New PR' . $this->preview->pull_request_id . ' version successfully deployed of ' . $this->application_name . '
$message = '✅ New PR' . $this->preview->pull_request_id . ' version successfully deployed of ' . $this->application_name . '
';
if ($this->preview->fqdn) {
$message .= '[Open Application](' . $this->preview->fqdn . ') | ';
}
$message .= '[Deployment logs](' . $this->deployment_url . ')';
} else {
$message = '✅ New version successfully deployed of ' . $this->application_name . '
$message = '✅ New version successfully deployed of ' . $this->application_name . '
';
if ($this->fqdn) {
$message .= '[Open Application](' . $this->fqdn . ') | ';

View File

@@ -44,10 +44,10 @@ class DeployedWithErrorNotification extends Notification implements ShouldQueue
public function via(object $notifiable): array
{
$channels = [];
$isEmailEnabled = data_get($notifiable, 'smtp.enabled');
$isDiscordEnabled = data_get($notifiable, 'discord.enabled');
$isSubscribedToEmailEvent = data_get($notifiable, 'smtp_notifications.deployments');
$isSubscribedToDiscordEvent = data_get($notifiable, 'discord_notifications.deployments');
$isEmailEnabled = data_get($notifiable, 'smtp_enabled');
$isDiscordEnabled = data_get($notifiable, 'discord_enabled');
$isSubscribedToEmailEvent = data_get($notifiable, 'smtp_notifications_deployments');
$isSubscribedToDiscordEvent = data_get($notifiable, 'discord_notifications_deployments');
if ($isEmailEnabled && $isSubscribedToEmailEvent) {
$channels[] = EmailChannel::class;
@@ -89,4 +89,4 @@ class DeployedWithErrorNotification extends Notification implements ShouldQueue
}
return $message;
}
}
}

View File

@@ -23,8 +23,8 @@ class TestNotification extends Notification implements ShouldQueue
$isSmtp = $this->type === 'smtp' || is_null($this->type);
$isDiscord = $this->type === 'discord' || is_null($this->type);
$isEmailEnabled = data_get($notifiable, 'smtp.enabled');
$isDiscordEnabled = data_get($notifiable, 'discord.enabled');
$isEmailEnabled = data_get($notifiable, 'smtp_enabled');
$isDiscordEnabled = data_get($notifiable, 'discord_enabled');
if ($isEmailEnabled && $isSmtp) {
$channels[] = EmailChannel::class;
@@ -50,4 +50,4 @@ class TestNotification extends Notification implements ShouldQueue
$message .= '[Go to your dashboard](' . base_url() . ')';
return $message;
}
}
}