Send notification on user mention

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2018-10-06 14:35:21 +02:00
parent 93c3c542e8
commit f66f4e0be0
3 changed files with 49 additions and 4 deletions

View File

@@ -29,6 +29,7 @@ use OCA\Deck\Db\Board;
use OCA\Deck\Db\BoardMapper;
use OCA\Deck\Db\CardMapper;
use OCA\Deck\Service\PermissionService;
use OCP\Comments\IComment;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\Notification\IManager;
@@ -134,6 +135,22 @@ class NotificationHelper {
}
}
public function sendMention(IComment $comment) {
foreach ($comment->getMentions() as $mention) {
$card = $this->cardMapper->find($comment->getObjectId());
$boardId = $this->cardMapper->findBoardId($card->getId());
$notification = $this->notificationManager->createNotification();
$notification
->setApp('deck')
->setUser((string) $mention['id'])
->setDateTime(new DateTime())
->setObject('card', (string) $card->getId())
->setSubject('card-comment-mentioned', [$card->getTitle(), $boardId, $this->currentUser])
->setMessage($comment->getMessage());
$this->notificationManager->notify($notification);
}
}
/**
* @param $boardId
* @return Board
@@ -160,4 +177,4 @@ class NotificationHelper {
return $notification;
}
}
}