From 814d3e2fc2a9312dcf07bc9c915ae4695bc61266 Mon Sep 17 00:00:00 2001 From: Robin Windey Date: Sun, 1 Dec 2024 15:09:33 +0000 Subject: [PATCH] Use absolute icon url (fix #280) --- lib/Notification/Notifier.php | 2 +- tests/Unit/Notification/NotifierTest.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index fef355a..ad18d38 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -111,7 +111,7 @@ public function prepare(INotification $notification, string $languageCode): INot $message = $notification->getSubjectParameters()['message']; $notification ->setParsedMessage($message) - ->setIcon($this->urlGenerator->imagePath(Application::APP_NAME, 'app-dark.svg')); + ->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath(Application::APP_NAME, 'app-dark.svg'))); return $notification; } diff --git a/tests/Unit/Notification/NotifierTest.php b/tests/Unit/Notification/NotifierTest.php index 3708c9e..6128ba3 100644 --- a/tests/Unit/Notification/NotifierTest.php +++ b/tests/Unit/Notification/NotifierTest.php @@ -160,6 +160,10 @@ public function testPrepareConstructsOcrErrorCorrectlyWithFileId() { $this->urlGenerator->expects($this->once()) ->method('imagePath') ->with('workflow_ocr', 'app-dark.svg') + ->willReturn('apps/workflow_ocr/app-dark.svg'); + $this->urlGenerator->expects($this->once()) + ->method('getAbsoluteURL') + ->with('apps/workflow_ocr/app-dark.svg') ->willReturn('http://localhost/index.php/apps/workflow_ocr/app-dark.svg'); $this->urlGenerator->expects($this->once()) ->method('linkToRouteAbsolute') @@ -204,6 +208,10 @@ public function testPrepareConstructsOcrErrorCorrectlyWithoutFile() { $this->urlGenerator->expects($this->once()) ->method('imagePath') ->with('workflow_ocr', 'app-dark.svg') + ->willReturn('apps/workflow_ocr/app-dark.svg'); + $this->urlGenerator->expects($this->once()) + ->method('getAbsoluteURL') + ->with('apps/workflow_ocr/app-dark.svg') ->willReturn('http://localhost/index.php/apps/workflow_ocr/app-dark.svg'); $this->urlGenerator->expects($this->never()) ->method('linkToRouteAbsolute'); @@ -251,6 +259,10 @@ public function testSendsFallbackNotificationWithoutFileInfoIfFileNotFoundWasThr $this->urlGenerator->expects($this->once()) ->method('imagePath') ->with('workflow_ocr', 'app-dark.svg') + ->willReturn('apps/workflow_ocr/app-dark.svg'); + $this->urlGenerator->expects($this->once()) + ->method('getAbsoluteURL') + ->with('apps/workflow_ocr/app-dark.svg') ->willReturn('http://localhost/index.php/apps/workflow_ocr/app-dark.svg'); $this->logger->expects($this->once()) ->method('error') @@ -297,6 +309,10 @@ public function testSendsFallbackNotificationWithoutFileInfoIfReturnedFileArrayW $this->urlGenerator->expects($this->once()) ->method('imagePath') ->with('workflow_ocr', 'app-dark.svg') + ->willReturn('apps/workflow_ocr/app-dark.svg'); + $this->urlGenerator->expects($this->once()) + ->method('getAbsoluteURL') + ->with('apps/workflow_ocr/app-dark.svg') ->willReturn('http://localhost/index.php/apps/workflow_ocr/app-dark.svg'); $this->logger->expects($this->once()) ->method('warning')