Add toggles for account created, subuser added/removed email notifications (#2309)

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
Nikolaos Karaolidis
2026-05-05 12:31:06 +01:00
committed by GitHub
parent 4ad305c709
commit 4464ccb469
6 changed files with 48 additions and 3 deletions
+30
View File
@@ -683,6 +683,36 @@ class Settings extends Page implements HasSchemas
->collapsible()
->collapsed()
->schema([
Toggle::make('PANEL_SEND_ACCOUNT_CREATED_NOTIFICATION')
->label(trans('admin/setting.misc.mail_notifications.account_created'))
->onIcon(TablerIcon::Check)
->offIcon(TablerIcon::X)
->onColor('success')
->offColor('danger')
->live()
->formatStateUsing(fn ($state): bool => (bool) $state)
->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_SEND_ACCOUNT_CREATED_NOTIFICATION', (bool) $state))
->default(env('PANEL_SEND_ACCOUNT_CREATED_NOTIFICATION', config('panel.email.send_account_created_notification'))),
Toggle::make('PANEL_SEND_ADDED_TO_SERVER_NOTIFICATION')
->label(trans('admin/setting.misc.mail_notifications.added_to_server'))
->onIcon(TablerIcon::Check)
->offIcon(TablerIcon::X)
->onColor('success')
->offColor('danger')
->live()
->formatStateUsing(fn ($state): bool => (bool) $state)
->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_SEND_ADDED_TO_SERVER_NOTIFICATION', (bool) $state))
->default(env('PANEL_SEND_ADDED_TO_SERVER_NOTIFICATION', config('panel.email.send_added_to_server_notification'))),
Toggle::make('PANEL_SEND_REMOVED_FROM_SERVER_NOTIFICATION')
->label(trans('admin/setting.misc.mail_notifications.removed_from_server'))
->onIcon(TablerIcon::Check)
->offIcon(TablerIcon::X)
->onColor('success')
->offColor('danger')
->live()
->formatStateUsing(fn ($state): bool => (bool) $state)
->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_SEND_REMOVED_FROM_SERVER_NOTIFICATION', (bool) $state))
->default(env('PANEL_SEND_REMOVED_FROM_SERVER_NOTIFICATION', config('panel.email.send_removed_from_server_notification'))),
Toggle::make('PANEL_SEND_INSTALL_NOTIFICATION')
->label(trans('admin/setting.misc.mail_notifications.server_installed'))
->onIcon(TablerIcon::Check)
@@ -29,6 +29,8 @@ class SubUserAddedListener
])
->sendToDatabase($event->subuser->user);
$event->subuser->user->notify(new AddedToServer($event->subuser->server));
if (config('panel.email.send_added_to_server_notification', true)) {
$event->subuser->user->notify(new AddedToServer($event->subuser->server));
}
}
}
@@ -17,6 +17,8 @@ class SubUserRemovedListener
->body(trans('notifications.user_removed.body', ['server' => $event->server->name], $locale))
->sendToDatabase($event->user);
$event->user->notify(new RemovedFromServer($event->server));
if (config('panel.email.send_removed_from_server_notification', true)) {
$event->user->notify(new RemovedFromServer($event->server));
}
}
}
+3 -1
View File
@@ -66,7 +66,9 @@ class UserCreationService
$this->connection->commit();
$user->notify(new AccountCreated($token ?? null));
if (config('panel.email.send_account_created_notification', true)) {
$user->notify(new AccountCreated($token ?? null));
}
return $user;
}
+6
View File
@@ -45,6 +45,12 @@ return [
],
'email' => [
// Should an email be sent to a new user when their account is created?
'send_account_created_notification' => env('PANEL_SEND_ACCOUNT_CREATED_NOTIFICATION', true),
// Should an email be sent to a user when they are added as a subuser to a server?
'send_added_to_server_notification' => env('PANEL_SEND_ADDED_TO_SERVER_NOTIFICATION', true),
// Should an email be sent to a user when they are removed as a subuser from a server?
'send_removed_from_server_notification' => env('PANEL_SEND_REMOVED_FROM_SERVER_NOTIFICATION', true),
// Should an email be sent to a server owner once their server has completed it's first install process?
'send_install_notification' => env('PANEL_SEND_INSTALL_NOTIFICATION', true),
// Should an email be sent to a server owner whenever their server is reinstalled?
+3
View File
@@ -116,6 +116,9 @@ return [
'mail_notifications' => [
'title' => 'Mail Notifications',
'helper' => 'Toggle which mail notifications should be sent to Users.',
'account_created' => 'Account Created',
'added_to_server' => 'Added to Server',
'removed_from_server' => 'Removed from Server',
'server_installed' => 'Server Installed',
'server_reinstalled' => 'Server Reinstalled',
'backup_completed' => 'Backup Completed',