Notifications: Do not use rich text for board/card

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2017-10-01 18:12:17 +02:00
committed by Julius Härtl
parent e8ecfce134
commit ed55b0db51
2 changed files with 15 additions and 28 deletions

View File

@@ -49,8 +49,7 @@ class Notifier implements INotifier {
IURLGenerator $url, IURLGenerator $url,
IUserManager $userManager, IUserManager $userManager,
CardMapper $cardMapper, CardMapper $cardMapper,
BoardMapper $boardMapper, BoardMapper $boardMapper
Definitions $definitions
) { ) {
$this->l10nFactory = $l10nFactory; $this->l10nFactory = $l10nFactory;
$this->url = $url; $this->url = $url;
@@ -67,10 +66,10 @@ class Notifier implements INotifier {
* @since 9.0.0 * @since 9.0.0
*/ */
public function prepare(INotification $notification, $languageCode) { public function prepare(INotification $notification, $languageCode) {
$l = $this->l10nFactory->get('deck', $languageCode);
if($notification->getApp() !== 'deck') { if($notification->getApp() !== 'deck') {
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
} }
$l = $this->l10nFactory->get('deck', $languageCode);
$notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('deck', 'deck-dark.svg'))); $notification->setIcon($this->url->getAbsoluteURL($this->url->imagePath('deck', 'deck-dark.svg')));
$params = $notification->getSubjectParameters(); $params = $notification->getSubjectParameters();
@@ -79,28 +78,13 @@ class Notifier implements INotifier {
$cardId = $notification->getObjectId(); $cardId = $notification->getObjectId();
$boardId = $this->cardMapper->findBoardId($cardId); $boardId = $this->cardMapper->findBoardId($cardId);
$notification->setParsedSubject( $notification->setParsedSubject(
(string) $l->t('The card "%s" on "%s" has reached its due date.', $notification->getSubjectParameters()) (string) $l->t('The card "%s" on "%s" has reached its due date.', $params)
);
$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],
],
]
); );
$notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#!/board/'.$boardId.'//card/'.$cardId.''); $notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#!/board/'.$boardId.'//card/'.$cardId.'');
break; break;
case 'board-shared': case 'board-shared':
$boardId = $notification->getObjectId(); $boardId = $notification->getObjectId();
$initiator = \OC::$server->getUserManager()->get($params[1]); $initiator = $this->userManager->get($params[1]);
if($initiator !== null) { if($initiator !== null) {
$dn = $initiator->getDisplayName(); $dn = $initiator->getDisplayName();
} else { } else {
@@ -108,19 +92,15 @@ class Notifier implements INotifier {
} }
$notification->setParsedSubject( $notification->setParsedSubject(
(string) $l->t('The board "%s" has been shared with you by %s.', [$params[0], $dn]) (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' => [ 'user' => [
'type' => 'user', 'type' => 'user',
'id' => $params[1], 'id' => $params[1],
'name' => $dn, 'name' => $dn,
], ]
'board' => [
'id' => null,
'type' => 'announcement',
'name' => $params[0],
],
] ]
); );
$notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#!/board/'.$boardId.'/'); $notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#!/board/'.$boardId.'/');

View File

@@ -0,0 +1,7 @@
<?php
/**
* Created by PhpStorm.
* User: jus
* Date: 01.10.17
* Time: 17:23
*/