diff --git a/modules/helpdesk/lib/Module/Helpdesk/HelpdeskContainerRegistrar.php b/modules/helpdesk/lib/Module/Helpdesk/HelpdeskContainerRegistrar.php index 8193de2..f8eb51b 100644 --- a/modules/helpdesk/lib/Module/Helpdesk/HelpdeskContainerRegistrar.php +++ b/modules/helpdesk/lib/Module/Helpdesk/HelpdeskContainerRegistrar.php @@ -145,7 +145,9 @@ final class HelpdeskContainerRegistrar implements ContainerRegistrar )); $container->set(HandoverNotificationService::class, static fn (AppContainer $c): HandoverNotificationService => new HandoverNotificationService( - $c->get(MailService::class) + $c->get(MailService::class), + appTitle(), + appUrl(), )); $container->set(HandoverService::class, static fn (AppContainer $c): HandoverService => new HandoverService( diff --git a/modules/helpdesk/lib/Module/Helpdesk/Service/HandoverNotificationService.php b/modules/helpdesk/lib/Module/Helpdesk/Service/HandoverNotificationService.php index 5829cd1..dc029e6 100644 --- a/modules/helpdesk/lib/Module/Helpdesk/Service/HandoverNotificationService.php +++ b/modules/helpdesk/lib/Module/Helpdesk/Service/HandoverNotificationService.php @@ -8,9 +8,24 @@ class HandoverNotificationService { public function __construct( private readonly MailService $mailService, + private readonly string $appTitle = '', + private readonly string $appUrl = '', ) { } + private function resolveAppTitle(): string + { + return $this->appTitle !== '' ? $this->appTitle : appTitle(); + } + + private function resolveAppUrl(string $path = ''): string + { + if ($this->appUrl !== '') { + return rtrim($this->appUrl, '/') . ($path !== '' ? '/' . ltrim($path, '/') : ''); + } + return appUrl($path); + } + /** * Notify the assignee that a handover was assigned to them. * @@ -29,7 +44,7 @@ class HandoverNotificationService $domainUrl = trim((string) ($handover['domain_url'] ?? '')); $dueDate = trim((string) ($handover['due_date'] ?? '')); $handoverId = (int) ($handover['id'] ?? 0); - $handoverUrl = appUrl('helpdesk/handovers/edit/' . $handoverId); + $handoverUrl = $this->resolveAppUrl('helpdesk/handovers/edit/' . $handoverId); $vars = [ 'assignee_name' => $assigneeName, @@ -38,10 +53,10 @@ class HandoverNotificationService 'domain_url' => $domainUrl !== '' ? $domainUrl : '—', 'due_date' => $dueDate !== '' ? $dueDate : '—', 'handover_url' => $handoverUrl, - 'app_name' => appTitle(), + 'app_name' => $this->resolveAppTitle(), ]; - $subject = sprintf('[%s] Ihnen wurde eine Übergabe zugewiesen', appTitle()); + $subject = sprintf('[%s] Ihnen wurde eine Übergabe zugewiesen', $this->resolveAppTitle()); $this->mailService->sendTemplate('handover_assigned', $vars, $toEmail, $subject); } @@ -69,7 +84,7 @@ class HandoverNotificationService $debitorName = trim((string) ($handover['debitor_name'] ?? '')); $domainUrl = trim((string) ($handover['domain_url'] ?? '')); $handoverId = (int) ($handover['id'] ?? 0); - $handoverUrl = appUrl('helpdesk/handovers/edit/' . $handoverId); + $handoverUrl = $this->resolveAppUrl('helpdesk/handovers/edit/' . $handoverId); $vars = [ 'manager_name' => $managerName, @@ -77,10 +92,10 @@ class HandoverNotificationService 'debitor_name' => $debitorName !== '' ? $debitorName : '—', 'domain_url' => $domainUrl !== '' ? $domainUrl : '—', 'handover_url' => $handoverUrl, - 'app_name' => appTitle(), + 'app_name' => $this->resolveAppTitle(), ]; - $subject = sprintf('[%s] Übergabe wurde zur Prüfung eingereicht', appTitle()); + $subject = sprintf('[%s] Übergabe wurde zur Prüfung eingereicht', $this->resolveAppTitle()); $this->mailService->sendTemplate('handover_review_requested', $vars, $toEmail, $subject); } diff --git a/modules/helpdesk/pages/helpdesk/handovers/filter-schema.php b/modules/helpdesk/pages/helpdesk/handovers/filter-schema.php index e9fe08c..f1c84e0 100644 --- a/modules/helpdesk/pages/helpdesk/handovers/filter-schema.php +++ b/modules/helpdesk/pages/helpdesk/handovers/filter-schema.php @@ -24,6 +24,10 @@ return gridFilterSchema([ 'search' => true, 'query' => ['type' => 'string'], ], + [ + 'key' => 'view', + 'type' => 'hidden', + ], [ 'key' => 'status', 'type' => 'select', diff --git a/modules/helpdesk/tests/Module/Helpdesk/Service/HandoverNotificationServiceTest.php b/modules/helpdesk/tests/Module/Helpdesk/Service/HandoverNotificationServiceTest.php index 3b837ec..55eb98d 100644 --- a/modules/helpdesk/tests/Module/Helpdesk/Service/HandoverNotificationServiceTest.php +++ b/modules/helpdesk/tests/Module/Helpdesk/Service/HandoverNotificationServiceTest.php @@ -11,7 +11,9 @@ class HandoverNotificationServiceTest extends TestCase private function createNotificationService(?MailService $mailService = null): HandoverNotificationService { return new HandoverNotificationService( - $mailService ?? $this->createMock(MailService::class) + $mailService ?? $this->createMock(MailService::class), + 'TestApp', + 'http://localhost', ); }