diff --git a/app/Livewire/LayoutPopups.php b/app/Livewire/LayoutPopups.php index dd7f14678..b6f06f808 100644 --- a/app/Livewire/LayoutPopups.php +++ b/app/Livewire/LayoutPopups.php @@ -17,10 +17,14 @@ public function testEvent() { $this->dispatch('success', 'Realtime events configured!'); } - public function disable() + public function disableSponsorship() { auth()->user()->update(['is_notification_sponsorship_enabled' => false]); } + public function disableNotifications() + { + auth()->user()->update(['is_notification_notifications_enabled' => false]); + } public function render() { return view('livewire.layout-popups'); diff --git a/app/Models/Team.php b/app/Models/Team.php index 656c4009b..7cb1601de 100644 --- a/app/Models/Team.php +++ b/app/Models/Team.php @@ -48,13 +48,15 @@ public function getRecepients($notification) } return explode(',', $recipients); } - static public function serverLimitReached() { + static public function serverLimitReached() + { $serverLimit = Team::serverLimit(); $team = currentTeam(); $servers = $team->servers->count(); return $servers >= $serverLimit; } - public function serverOverflow() { + public function serverOverflow() + { if ($this->serverLimit() < $this->servers->count()) { return true; } @@ -170,4 +172,17 @@ public function trialEndedButSubscribed() ]); } } + public function isAnyNotificationEnabled() + { + if (isCloud()) { + return true; + } + if (!data_get(auth()->user(), 'is_notification_notifications_enabled')) { + return true; + } + if ($this->smtp_enabled || $this->resend_enabled || $this->discord_enabled || $this->telegram_enabled || $this->use_instance_email_settings) { + return true; + } + return false; + } } diff --git a/database/migrations/2024_03_07_115054_add_notifications_notification_disable.php b/database/migrations/2024_03_07_115054_add_notifications_notification_disable.php new file mode 100644 index 000000000..8633b971e --- /dev/null +++ b/database/migrations/2024_03_07_115054_add_notifications_notification_disable.php @@ -0,0 +1,28 @@ +boolean('is_notification_notifications_enabled')->default(true); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('is_notification_notifications_enabled'); + }); + } +}; diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 3bd1730be..65d2f0736 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -150,7 +150,17 @@ class="{{ request()->is('subscription*') ? 'text-warning icon' : 'icon' }}" @endif - +