From ed55b0db5119a8cf0b256aeb08b92789c9fdebae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Sun, 1 Oct 2017 18:12:17 +0200 Subject: [PATCH] Notifications: Do not use rich text for board/card MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Notification/Notifier.php | 36 ++++++------------------ tests/unit/Notification/NotifierTest.php | 7 +++++ 2 files changed, 15 insertions(+), 28 deletions(-) create mode 100644 tests/unit/Notification/NotifierTest.php diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index e884ed879..e85d5a6d5 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -49,8 +49,7 @@ class Notifier implements INotifier { IURLGenerator $url, IUserManager $userManager, CardMapper $cardMapper, - BoardMapper $boardMapper, - Definitions $definitions + BoardMapper $boardMapper ) { $this->l10nFactory = $l10nFactory; $this->url = $url; @@ -67,10 +66,10 @@ class Notifier implements INotifier { * @since 9.0.0 */ public function prepare(INotification $notification, $languageCode) { + $l = $this->l10nFactory->get('deck', $languageCode); if($notification->getApp() !== 'deck') { throw new \InvalidArgumentException(); } - $l = $this->l10nFactory->get('deck', $languageCode); $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('deck', 'deck-dark.svg'))); $params = $notification->getSubjectParameters(); @@ -79,28 +78,13 @@ class Notifier implements INotifier { $cardId = $notification->getObjectId(); $boardId = $this->cardMapper->findBoardId($cardId); $notification->setParsedSubject( - (string) $l->t('The card "%s" on "%s" has reached its due date.', $notification->getSubjectParameters()) - ); - $notification->setRichSubject( - (string) $l->t('The card {card} on {board} has reached its due date.'), - [ - 'card' => [ - 'id' => null, - 'type' => 'announcement', - 'name' => $params[0], - ], - 'board' => [ - 'id' => null, - 'type' => 'announcement', - 'name' => $params[1], - ], - ] + (string) $l->t('The card "%s" on "%s" has reached its due date.', $params) ); $notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#!/board/'.$boardId.'//card/'.$cardId.''); break; case 'board-shared': $boardId = $notification->getObjectId(); - $initiator = \OC::$server->getUserManager()->get($params[1]); + $initiator = $this->userManager->get($params[1]); if($initiator !== null) { $dn = $initiator->getDisplayName(); } else { @@ -108,19 +92,15 @@ class Notifier implements INotifier { } $notification->setParsedSubject( (string) $l->t('The board "%s" has been shared with you by %s.', [$params[0], $dn]) - )->setRichSubject( - (string) $l->t('{user} has shared the board {board} with you.'), + ); + $notification->setRichSubject( + (string) $l->t('{user} has shared the board %s with you.', [$params[0]]), [ 'user' => [ 'type' => 'user', 'id' => $params[1], 'name' => $dn, - ], - 'board' => [ - 'id' => null, - 'type' => 'announcement', - 'name' => $params[0], - ], + ] ] ); $notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#!/board/'.$boardId.'/'); diff --git a/tests/unit/Notification/NotifierTest.php b/tests/unit/Notification/NotifierTest.php new file mode 100644 index 000000000..592fc4f84 --- /dev/null +++ b/tests/unit/Notification/NotifierTest.php @@ -0,0 +1,7 @@ +