зеркало из https://github.com/nextcloud/deck.git
Emit activity events in BoardService
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Родитель
6a5b4fe40c
Коммит
c32ab5648c
|
@ -23,6 +23,8 @@
|
|||
|
||||
namespace OCA\Deck\Service;
|
||||
|
||||
use OCA\Deck\Activity\ActivityManager;
|
||||
use OCA\Deck\Activity\ChangeSet;
|
||||
use OCA\Deck\Db\Acl;
|
||||
use OCA\Deck\Db\AclMapper;
|
||||
use OCA\Deck\Db\AssignedUsersMapper;
|
||||
|
@ -51,6 +53,7 @@ class BoardService {
|
|||
private $userManager;
|
||||
private $groupManager;
|
||||
private $userId;
|
||||
private $activityManager;
|
||||
|
||||
public function __construct(
|
||||
BoardMapper $boardMapper,
|
||||
|
@ -62,6 +65,7 @@ class BoardService {
|
|||
AssignedUsersMapper $assignedUsersMapper,
|
||||
IUserManager $userManager,
|
||||
IGroupManager $groupManager,
|
||||
ActivityManager $activityManager,
|
||||
$userId
|
||||
) {
|
||||
$this->boardMapper = $boardMapper;
|
||||
|
@ -73,6 +77,7 @@ class BoardService {
|
|||
$this->assignedUsersMapper = $assignedUsersMapper;
|
||||
$this->userManager = $userManager;
|
||||
$this->groupManager = $groupManager;
|
||||
$this->activityManager = $activityManager;
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
|
@ -244,7 +249,7 @@ class BoardService {
|
|||
$board->setTitle($title);
|
||||
$board->setOwner($userId);
|
||||
$board->setColor($color);
|
||||
$new_board = $this->boardMapper->insert($board);
|
||||
$new_board = $this->boardMapper->insert($board);
|
||||
|
||||
// create new labels
|
||||
$default_labels = [
|
||||
|
@ -270,6 +275,8 @@ class BoardService {
|
|||
'PERMISSION_MANAGE' => $permissions[Acl::PERMISSION_MANAGE],
|
||||
'PERMISSION_SHARE' => $permissions[Acl::PERMISSION_SHARE]
|
||||
]);
|
||||
$event = $this->activityManager->createEvent(ActivityManager::DECK_OBJECT_BOARD, $new_board, ActivityManager::SUBJECT_BOARD_CREATE);
|
||||
$this->activityManager->sendToUsers($event);
|
||||
return $new_board;
|
||||
|
||||
}
|
||||
|
@ -291,7 +298,9 @@ class BoardService {
|
|||
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ);
|
||||
$board = $this->find($id);
|
||||
$board->setDeletedAt(time());
|
||||
$this->boardMapper->update($board);
|
||||
$board = $this->boardMapper->update($board);
|
||||
$event = $this->activityManager->createEvent(ActivityManager::DECK_OBJECT_BOARD, $board, ActivityManager::SUBJECT_BOARD_DELETE);
|
||||
$this->activityManager->sendToUsers($event);
|
||||
return $board;
|
||||
}
|
||||
|
||||
|
@ -311,7 +320,10 @@ class BoardService {
|
|||
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_READ);
|
||||
$board = $this->find($id);
|
||||
$board->setDeletedAt(0);
|
||||
return $this->boardMapper->update($board);
|
||||
$board = $this->boardMapper->update($board);
|
||||
$event = $this->activityManager->createEvent(ActivityManager::DECK_OBJECT_BOARD, $board, ActivityManager::SUBJECT_BOARD_RESTORE);
|
||||
$this->activityManager->sendToUsers($event);
|
||||
return $board;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -322,7 +334,7 @@ class BoardService {
|
|||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws BadRequestException
|
||||
*/
|
||||
public function deleteForce($id) {
|
||||
public function deleteForce($id) {
|
||||
if (is_numeric($id) === false) {
|
||||
throw new BadRequestException('id must be a number');
|
||||
}
|
||||
|
@ -363,11 +375,15 @@ class BoardService {
|
|||
|
||||
$this->permissionService->checkPermission($this->boardMapper, $id, Acl::PERMISSION_MANAGE);
|
||||
$board = $this->find($id);
|
||||
$changes = new ChangeSet($board);
|
||||
$board->setTitle($title);
|
||||
$board->setColor($color);
|
||||
$board->setArchived($archived);
|
||||
$this->boardMapper->mapOwner($board);
|
||||
return $this->boardMapper->update($board);
|
||||
$changes->setAfter($board);
|
||||
$this->boardMapper->update($board); // operate on clone so we can check for updated fields
|
||||
$this->boardMapper->mapOwner($newBoard);
|
||||
$this->activityManager->triggerUpdateEvents(ActivityManager::DECK_OBJECT_BOARD, $changes->getAfter(), ActivityManager::SUBJECT_BOARD_UPDATE, $changes->getBefore());
|
||||
return $board;
|
||||
}
|
||||
|
||||
|
||||
|
@ -422,6 +438,8 @@ class BoardService {
|
|||
|
||||
$newAcl = $this->aclMapper->insert($acl);
|
||||
$this->boardMapper->mapAcl($newAcl);
|
||||
$event = $this->activityManager->createEvent(ActivityManager::DECK_OBJECT_BOARD, $newAcl, ActivityManager::SUBJECT_BOARD_SHARE);
|
||||
$this->activityManager->sendToUsers($event);
|
||||
return $newAcl;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче