Add notification on card assignment to user

Signed-off-by: Steav <steav8@gmail.com>
This commit is contained in:
Steav
2018-07-22 13:41:56 +02:00
committed by Julius Härtl
parent a4044eff30
commit 77472b978d
7 changed files with 43 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ OC.L10N.register(
"Are you sure you want to delete the stack with all of its data?" : "Möchtest du diesen Stapel mit allen Daten wirklich löschen?",
"Personal" : "Persönlich",
"The card \"%s\" on \"%s\" has reached its due date." : "Die Karte \"%s\" auf \"%s\" ist überfällig.",
"The card \"%s\" on \"%s\" has been assigned to you by %s." : "Die Karte \"%s\" wurde Dir auf \"%s\" von %s zugewiesen.",
"The board \"%s\" has been shared with you by %s." : "Das Board \"%s\" wurde von %s mit Dir geteilt.",
"{user} has shared the board %s with you." : "{user} hat das Board %s mit Dir geteilt.",
"No data was provided to create an attachment." : "Es wurde keine Daten zum Erstellen eines Anhangs bereitgestellt.",

View File

@@ -8,6 +8,7 @@
"Are you sure you want to delete the stack with all of its data?" : "Möchtest du diesen Stapel mit allen Daten wirklich löschen?",
"Personal" : "Persönlich",
"The card \"%s\" on \"%s\" has reached its due date." : "Die Karte \"%s\" auf \"%s\" ist überfällig.",
"The card \"%s\" on \"%s\" has been assigned to you by %s." : "Die Karte \"%s\" wurde Dir auf \"%s\" von %s zugewiesen.",
"The board \"%s\" has been shared with you by %s." : "Das Board \"%s\" wurde von %s mit Dir geteilt.",
"{user} has shared the board %s with you." : "{user} hat das Board %s mit Dir geteilt.",
"No data was provided to create an attachment." : "Es wurde keine Daten zum Erstellen eines Anhangs bereitgestellt.",

View File

@@ -10,6 +10,7 @@ OC.L10N.register(
"Are you sure you want to delete the stack with all of its data?" : "Möchten Sie diesen Stapel mit allen Daten wirklich löschen?",
"Personal" : "Persönlich",
"The card \"%s\" on \"%s\" has reached its due date." : "Die Karte \"%s\" auf \"%s\" ist überfällig.",
"The card \"%s\" on \"%s\" has been assigned to you by %s." : "Die Karte \"%s\" wurde Ihnen auf \"%s\" von %s zugewiesen.",
"The board \"%s\" has been shared with you by %s." : "Das Board \"%s\" wurde von %s mit Ihnen geteilt.",
"{user} has shared the board %s with you." : "{user} hat das Board %s mit Ihnen geteilt.",
"No data was provided to create an attachment." : "Es wurde keine Daten zum Erstellen eines Anhangs bereitgestellt.",

View File

@@ -9,6 +9,7 @@
"Personal" : "Persönlich",
"The card \"%s\" on \"%s\" has reached its due date." : "Die Karte \"%s\" auf \"%s\" ist überfällig.",
"The board \"%s\" has been shared with you by %s." : "Das Board \"%s\" wurde von %s mit Ihnen geteilt.",
"The card \"%s\" on \"%s\" has been assigned to you by %s." : "Die Karte \"%s\" wurde Ihnen auf \"%s\" von %s zugewiesen.",
"{user} has shared the board %s with you." : "{user} hat das Board %s mit Ihnen geteilt.",
"No data was provided to create an attachment." : "Es wurde keine Daten zum Erstellen eines Anhangs bereitgestellt.",
"Finished" : "Abgeschlossen",

View File

@@ -94,6 +94,24 @@ class NotificationHelper {
$this->cardMapper->markNotified($card);
}
public function sendCardAssigned($card, $userId) {
$boardId = $this->cardMapper->findBoardId($card->getId());
$board = $this->getBoard($boardId);
$notification = $this->notificationManager->createNotification();
$notification
->setApp('deck')
->setUser((string) $userId)
->setDateTime(new DateTime())
->setObject('card', $card->getId())
->setSubject('card-assigned', [
$card->getTitle(),
$board->getTitle(),
$this->currentUser
]);
$this->notificationManager->notify($notification);
}
/**
* Send notifications that a board was shared with a user/group
*

View File

@@ -73,6 +73,18 @@ class Notifier implements INotifier {
$params = $notification->getSubjectParameters();
switch ($notification->getSubject()) {
case 'card-assigned':
$cardId = $notification->getObjectId();
$boardId = $this->cardMapper->findBoardId($cardId);
$initiator = $this->userManager->get($params[2]);
if ($initiator !== null) {
$params[2] = $initiator->getDisplayName();
}
$notification->setParsedSubject(
(string) $l->t('The card "%s" on "%s" has been assigned to you by %s.', $params)
);
$notification->setLink($this->url->linkToRouteAbsolute('deck.page.index') . '#!/board/' . $boardId . '//card/' . $cardId . '');
break;
case 'card-overdue':
$cardId = $notification->getObjectId();
$boardId = $this->cardMapper->findBoardId($cardId);

View File

@@ -29,6 +29,7 @@ use OCA\Deck\Db\Card;
use OCA\Deck\Db\CardMapper;
use OCA\Deck\Db\Acl;
use OCA\Deck\Db\StackMapper;
use OCA\Deck\Notification\NotificationHelper;
use OCA\Deck\NotFoundException;
use OCA\Deck\StatusException;
@@ -39,14 +40,16 @@ class CardService {
private $stackMapper;
private $permissionService;
private $boardService;
private $notificationHelper;
private $assignedUsersMapper;
private $attachmentService;
public function __construct(CardMapper $cardMapper, StackMapper $stackMapper, PermissionService $permissionService, BoardService $boardService, AssignedUsersMapper $assignedUsersMapper, AttachmentService $attachmentService) {
public function __construct(CardMapper $cardMapper, StackMapper $stackMapper, PermissionService $permissionService, BoardService $boardService, NotificationHelper $notificationHelper, AssignedUsersMapper $assignedUsersMapper, AttachmentService $attachmentService) {
$this->cardMapper = $cardMapper;
$this->stackMapper = $stackMapper;
$this->permissionService = $permissionService;
$this->boardService = $boardService;
$this->notificationHelper = $notificationHelper;
$this->assignedUsersMapper = $assignedUsersMapper;
$this->attachmentService = $attachmentService;
}
@@ -202,6 +205,11 @@ class CardService {
return false;
}
}
/* Notify user about the card assignment */
$card = $this->cardMapper->find($cardId);
$this->notificationHelper->sendCardAssigned($card, $userId);
$assignment = new AssignedUsers();
$assignment->setCardId($cardId);
$assignment->setParticipant($userId);