Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use OCP\Notification\AlreadyProcessedException;
use OCP\Notification\INotification;
use OCP\Notification\INotifier;
use OCP\Notification\IAction;

class Notifier implements INotifier {
/** @var IFactory */
Expand Down Expand Up @@ -120,6 +121,7 @@ public function prepare(INotification $notification, string $languageCode): INot
]
);
$notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#/board/' . $boardId . '/card/' . $cardId . '');
$notification = $this->addActionButton($notification, $l->t('View card'));
break;
case 'card-overdue':
$cardId = $notification->getObjectId();
Expand All @@ -131,6 +133,9 @@ public function prepare(INotification $notification, string $languageCode): INot
(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 = $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;
case 'card-comment-mentioned':
$cardId = $notification->getObjectId();
Expand Down Expand Up @@ -161,6 +166,7 @@ public function prepare(INotification $notification, string $languageCode): INot
$notification->setParsedMessage($notification->getMessageParameters()['message']);
}
$notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#/board/' . $boardId . '/card/' . $cardId . '');
$notification = $this->addActionButton($notification, $l->t('View card'));
break;
case 'board-shared':
$boardId = $notification->getObjectId();
Expand All @@ -187,8 +193,34 @@ public function prepare(INotification $notification, string $languageCode): INot
]
);
$notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#/board/' . $boardId . '/');
$notification = $this->addActionButton($notification, $l->t('View board'));
break;
}
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;
}

}