Send notifications when a board gets shared
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
committed by
Julius Härtl
parent
e0bab217a0
commit
52fc971529
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace OCA\Deck\Service;
|
||||
|
||||
use DateTime;
|
||||
use OCA\Deck\ArchivedItemException;
|
||||
use OCA\Deck\Db\Acl;
|
||||
use OCA\Deck\Db\AclMapper;
|
||||
@@ -42,13 +43,15 @@ class BoardService {
|
||||
private $aclMapper;
|
||||
private $l10n;
|
||||
private $permissionService;
|
||||
private $userId;
|
||||
|
||||
public function __construct(BoardMapper $boardMapper, IL10N $l10n, LabelMapper $labelMapper, AclMapper $aclMapper, PermissionService $permissionService) {
|
||||
public function __construct(BoardMapper $boardMapper, IL10N $l10n, LabelMapper $labelMapper, AclMapper $aclMapper, PermissionService $permissionService, $userId) {
|
||||
$this->boardMapper = $boardMapper;
|
||||
$this->labelMapper = $labelMapper;
|
||||
$this->aclMapper = $aclMapper;
|
||||
$this->l10n = $l10n;
|
||||
$this->permissionService = $permissionService;
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
public function findAll($userInfo) {
|
||||
@@ -209,6 +212,20 @@ class BoardService {
|
||||
$acl->setPermissionEdit($edit);
|
||||
$acl->setPermissionShare($share);
|
||||
$acl->setPermissionManage($manage);
|
||||
/* Notify users about the shared board */
|
||||
if($acl->getType() === Acl::PERMISSION_TYPE_USER) {
|
||||
$board = $this->boardMapper->find($boardId);
|
||||
$initiator = \OC::$server->getUserManager()->get($this->userId);
|
||||
$manager = \OC::$server->getNotificationManager();
|
||||
$notification = $manager->createNotification();
|
||||
$notification
|
||||
->setApp('deck')
|
||||
->setUser($participant['uid'])
|
||||
->setDateTime(new DateTime())
|
||||
->setObject('board', $boardId)// $type and $id
|
||||
->setSubject('board-shared', [$board->getTitle(), $initiator->getUID()]);
|
||||
$manager->notify($notification);
|
||||
}
|
||||
$newAcl = $this->aclMapper->insert($acl);
|
||||
$this->boardMapper->mapAcl($newAcl);
|
||||
return $newAcl;
|
||||
|
||||
Reference in New Issue
Block a user