Compare commits

...

1 Commits

Author SHA1 Message Date
Jakob Röhrl
5c9fc601fc interactive notifications
Signed-off-by: Jakob Röhrl <jakob.roehrl@web.de>
2021-03-11 10:57:30 +01:00

View File

@@ -31,6 +31,7 @@ use OCP\L10N\IFactory;
use OCP\Notification\AlreadyProcessedException; use OCP\Notification\AlreadyProcessedException;
use OCP\Notification\INotification; use OCP\Notification\INotification;
use OCP\Notification\INotifier; use OCP\Notification\INotifier;
use OCP\Notification\IAction;
class Notifier implements INotifier { class Notifier implements INotifier {
/** @var IFactory */ /** @var IFactory */
@@ -120,6 +121,7 @@ class Notifier implements INotifier {
] ]
); );
$notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#/board/' . $boardId . '/card/' . $cardId . ''); $notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#/board/' . $boardId . '/card/' . $cardId . '');
$notification = $this->addActionButton($notification, $l->t('View card'));
break; break;
case 'card-overdue': case 'card-overdue':
$cardId = $notification->getObjectId(); $cardId = $notification->getObjectId();
@@ -131,6 +133,9 @@ class Notifier implements INotifier {
(string) $l->t('The card "%s" on "%s" has reached its due date.', $params) (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 . ''); $notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#/board/' . $boardId . '/card/' . $cardId . '');
$notification = $this->addActionButton($notification, $l->t('View card'));
// $notification = $this->addActionButton($notification, $l->t('Set due to tomorrow'), false);
$notification = $this->addActionButtonChangeDueDate($notification, $l->t('Remove due date'), false);
break; break;
case 'card-comment-mentioned': case 'card-comment-mentioned':
$cardId = $notification->getObjectId(); $cardId = $notification->getObjectId();
@@ -161,6 +166,7 @@ class Notifier implements INotifier {
$notification->setParsedMessage($notification->getMessageParameters()['message']); $notification->setParsedMessage($notification->getMessageParameters()['message']);
} }
$notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#/board/' . $boardId . '/card/' . $cardId . ''); $notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#/board/' . $boardId . '/card/' . $cardId . '');
$notification = $this->addActionButton($notification, $l->t('View card'));
break; break;
case 'board-shared': case 'board-shared':
$boardId = $notification->getObjectId(); $boardId = $notification->getObjectId();
@@ -187,8 +193,34 @@ class Notifier implements INotifier {
] ]
); );
$notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#/board/' . $boardId . '/'); $notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#/board/' . $boardId . '/');
$notification = $this->addActionButton($notification, $l->t('View board'));
break; break;
} }
return $notification; return $notification;
} }
protected function addActionButton(INotification $notification, string $label, bool $primary = true): INotification {
$action = $notification->createAction();
$action->setLabel($label)
->setParsedLabel($label)
->setLink($notification->getLink(), IAction::TYPE_WEB)
->setPrimary($primary);
$notification->addParsedAction($action);
return $notification;
}
protected function addActionButtonChangeDueDate(INotification $notification, string $label, bool $primary = true): INotification {
$action = $notification->createAction();
$action->setLabel($label)
->setParsedLabel($label)
->setLink($notification->getLink(), IAction::TYPE_WEB)
->setPrimary($primary);
$notification->addParsedAction($action);
return $notification;
}
} }