Use recipient language for database notifications (#2008)

This commit is contained in:
Boy132 2025-12-17 20:34:12 +01:00 committed by GitHub
parent 9d1e7f510f
commit 5a47948a93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 8 deletions

View File

@ -14,14 +14,16 @@ class ServerInstalledListener
{
$event->server->loadMissing('user');
$locale = $event->server->user->language ?? 'en';
Notification::make()
->status($event->successful ? 'success' : 'danger')
->title(trans('notifications.' . ($event->initialInstall ? 'installation' : 'reinstallation') . '_' . ($event->successful ? 'completed' : 'failed')))
->body(trans('server/setting.server_info.server_name', ['name' => $event->server->name]))
->title(trans('notifications.' . ($event->initialInstall ? 'installation' : 'reinstallation') . '_' . ($event->successful ? 'completed' : 'failed'), locale: $locale))
->body(trans('server/setting.server_info.server_name', ['name' => $event->server->name], $locale))
->actions([
Action::make('view')
->button()
->label(trans('notifications.open_server'))
->label(trans('notifications.open_server', locale: $locale))
->markAsRead()
->url(fn () => Console::getUrl(panel: 'server', tenant: $event->server)),
])

View File

@ -15,13 +15,15 @@ class SubUserAddedListener
$event->subuser->loadMissing('server');
$event->subuser->loadMissing('user');
$locale = $event->subuser->user->language ?? 'en';
Notification::make()
->title(trans('notifications.user_added.title'))
->body(trans('notifications.user_added.body', ['server' => $event->subuser->server->name]))
->title(trans('notifications.user_added.title', locale: $locale))
->body(trans('notifications.user_added.body', ['server' => $event->subuser->server->name], $locale))
->actions([
Action::make('view')
->button()
->label(trans('notifications.open_server'))
->label(trans('notifications.open_server', locale: $locale))
->markAsRead()
->url(fn () => Console::getUrl(panel: 'server', tenant: $event->subuser->server)),
])

View File

@ -10,9 +10,11 @@ class SubUserRemovedListener
{
public function handle(SubUserRemoved $event): void
{
$locale = $event->user->language ?? 'en';
Notification::make()
->title(trans('notifications.user_removed.title'))
->body(trans('notifications.user_removed.body', ['server' => $event->server->name]))
->title(trans('notifications.user_removed.title', locale: $locale))
->body(trans('notifications.user_removed.body', ['server' => $event->server->name], $locale))
->sendToDatabase($event->user);
$event->user->notify(new RemovedFromServer($event->server));