Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix notifications

Andras Bacsai9995663f0126
diff --git a/app/Livewire/Notifications/Discord.php b/app/Livewire/Notifications/Discord.php
index 77d8f31dea..7a177a2278 100644
--- a/app/Livewire/Notifications/Discord.php
+++ b/app/Livewire/Notifications/Discord.php
@@ -41,7 +41,7 @@ class Discord extends Component
$this->team = auth()->user()->currentTeam();
$this->syncData();
} catch (\Throwable $e) {
- handleError($e, $this);
+ return handleError($e, $this);
}
}
@@ -57,11 +57,8 @@ class Discord extends Component
$this->team->discord_notifications_database_backups = $this->discordNotificationsDatabaseBackups;
$this->team->discord_notifications_scheduled_tasks = $this->discordNotificationsScheduledTasks;
$this->team->discord_notifications_server_disk_usage = $this->discordNotificationsServerDiskUsage;
- try {
- $this->saveModel();
- } catch (\Throwable $e) {
- return handleError($e, $this);
- }
+ $this->team->save();
+ refreshSession();
} else {
$this->discordEnabled = $this->team->discord_enabled;
$this->discordWebhookUrl = $this->team->discord_webhook_url;
@@ -74,6 +71,22 @@ class Discord extends Component
}
}
+ public function instantSaveDiscordEnabled()
+ {
+ try {
+ $this->validate([
+ 'discordWebhookUrl' => 'required',
+ ], [
+ 'discordWebhookUrl.required' => 'Discord Webhook URL is required.',
+ ]);
+ $this->saveModel();
+ } catch (\Throwable $e) {
+ $this->discordEnabled = false;
+
+ return handleError($e, $this);
+ }
+ }
+
public function instantSave()
{
try {
@@ -96,7 +109,7 @@ class Discord extends Component
public function saveModel()
{
- $this->team->save();
+ $this->syncData(true);
refreshSession();
$this->dispatch('success', 'Settings saved.');
}
diff --git a/app/Livewire/Notifications/Email.php b/app/Livewire/Notifications/Email.php
index ae053b8be4..b49638b488 100644
--- a/app/Livewire/Notifications/Email.php
+++ b/app/Livewire/Notifications/Email.php
@@ -108,6 +108,7 @@ class Email extends Component
$this->team->resend_enabled = $this->resendEnabled;
$this->team->resend_api_key = $this->resendApiKey;
$this->team->save();
+ refreshSession();
} else {
$this->smtpEnabled = $this->team->smtp_enabled;
$this->smtpFromAddress = $this->team->smtp_from_address;
@@ -170,8 +171,8 @@ class Email extends Component
'smtpHost' => 'required',
'smtpPort' => 'required|numeric',
], [
- 'smtpHost.required' => 'SMTP Host is required',
- 'smtpPort.required' => 'SMTP Port is required',
+ 'smtpHost.required' => 'SMTP Host is required.',
+ 'smtpPort.required' => 'SMTP Port is required.',
]);
$this->resendEnabled = false;
$this->saveModel();
@@ -186,9 +187,8 @@ class Email extends Component
{
try {
$this->validate([
- 'resendApiKey' => 'required',
], [
- 'resendApiKey.required' => 'Resend API Key is required',
+ 'resendApiKey.required' => 'Resend API Key is required.',
]);
$this->smtpEnabled = false;
$this->saveModel();
diff --git a/app/Livewire/Notifications/Telegram.php b/app/Livewire/Notifications/Telegram.php
index 06feb8804a..15ec205778 100644
--- a/app/Livewire/Notifications/Telegram.php
+++ b/app/Livewire/Notifications/Telegram.php
@@ -81,11 +81,8 @@ class Telegram extends Component
$this->team->telegram_notifications_database_backups_message_thread_id = $this->telegramNotificationsDatabaseBackupsMessageThreadId;
$this->team->telegram_notifications_scheduled_tasks_thread_id = $this->telegramNotificationsScheduledTasksThreadId;
$this->team->telegram_notifications_server_disk_usage = $this->telegramNotificationsServerDiskUsage;
- try {
- $this->saveModel();
- } catch (\Throwable $e) {
- return handleError($e, $this);
- }
+ $this->team->save();
+ refreshSession();
} else {
$this->telegramEnabled = $this->team->telegram_enabled;
$this->telegramToken = $this->team->telegram_token;
@@ -125,9 +122,27 @@ class Telegram extends Component
}
}
+ public function instantSaveTelegramEnabled()
+ {
+ try {
+ $this->validate([
+ 'telegramToken' => 'required',
+ 'telegramChatId' => 'required',
+ ], [
+ 'telegramToken.required' => 'Telegram Token is required.',
+ 'telegramChatId.required' => 'Telegram Chat ID is required.',
+ ]);
+ $this->saveModel();
+ } catch (\Throwable $e) {
+ $this->telegramEnabled = false;
+
+ return handleError($e, $this);
+ }
+ }
+
public function saveModel()
{
- $this->team->save();
+ $this->syncData(true);
refreshSession();
$this->dispatch('success', 'Settings saved.');
}
diff --git a/resources/views/components/notification/navbar.blade.php b/resources/views/components/notification/navbar.blade.php
index 0fbbc69a23..b43fc38afb 100644
--- a/resources/views/components/notification/navbar.blade.php
+++ b/resources/views/components/notification/navbar.blade.php
@@ -3,15 +3,15 @@
<div class="subtitle">Get notified about your infrastructure.</div>
<div class="navbar-main">
<nav class="flex items-center gap-6 min-h-10">
- <a class="{{ request()->routeIs('notifications.email') ? 'dark:text-white' : '' }}"
+ <a wire:navigate class="{{ request()->routeIs('notifications.email') ? 'dark:text-white' : '' }}"
href="{{ route('notifications.email') }}">
<button>Email</button>
</a>
- <a class="{{ request()->routeIs('notifications.telegram') ? 'dark:text-white' : '' }}"
+ <a wire:navigate class="{{ request()->routeIs('notifications.telegram') ? 'dark:text-white' : '' }}"
href="{{ route('notifications.telegram') }}">
<button>Telegram</button>
</a>
- <a class="{{ request()->routeIs('notifications.discord') ? 'dark:text-white' : '' }}"
+ <a wire:navigate class="{{ request()->routeIs('notifications.discord') ? 'dark:text-white' : '' }}"
href="{{ route('notifications.discord') }}">
<button>Discord</button>
</a>
diff --git a/resources/views/livewire/notifications/discord.blade.php b/resources/views/livewire/notifications/discord.blade.php
index bb94c86f0d..af6f98b0ab 100644
--- a/resources/views/livewire/notifications/discord.blade.php
+++ b/resources/views/livewire/notifications/discord.blade.php
@@ -17,7 +17,7 @@
@endif
</div>
<div class="w-32">
- <x-forms.checkbox instantSave id="discordEnabled" label="Enabled" />
+ <x-forms.checkbox instantSave="instantSaveDiscordEnabled" id="discordEnabled" label="Enabled" />
</div>
<x-forms.input type="password"
helper="Generate a webhook in Discord.<br>Example: https://discord.com/api/webhooks/...." required
diff --git a/resources/views/livewire/notifications/telegram.blade.php b/resources/views/livewire/notifications/telegram.blade.php
index 91fab70866..76378ada1a 100644
--- a/resources/views/livewire/notifications/telegram.blade.php
+++ b/resources/views/livewire/notifications/telegram.blade.php
@@ -17,7 +17,7 @@
@endif
</div>
<div class="w-32">
- <x-forms.checkbox instantSave id="telegramEnabled" label="Enabled" />
+ <x-forms.checkbox instantSave="instantSaveTelegramEnabled" id="telegramEnabled" label="Enabled" />
</div>
<div class="flex gap-2">