@@ -114,7 +114,7 @@ class AssignmentMapper extends QBMapper implements IPermissionMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function isUserAssigned($cardId, $userId): bool {
|
public function isUserAssigned($cardId, $userId): bool {
|
||||||
$assignments = $this->find($cardId);
|
$assignments = $this->findAll($cardId);
|
||||||
foreach ($assignments as $assignment) {
|
foreach ($assignments as $assignment) {
|
||||||
$origin = $this->getOrigin($assignment);
|
$origin = $this->getOrigin($assignment);
|
||||||
if ($origin instanceof User && $assignment->getParticipant() === $userId) {
|
if ($origin instanceof User && $assignment->getParticipant() === $userId) {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OCA\Deck\Notification;
|
|||||||
use DateTime;
|
use DateTime;
|
||||||
use OCA\Deck\AppInfo\Application;
|
use OCA\Deck\AppInfo\Application;
|
||||||
use OCA\Deck\Db\Acl;
|
use OCA\Deck\Db\Acl;
|
||||||
use OCA\Deck\Db\AssignedUsersMapper;
|
use OCA\Deck\Db\AssignmentMapper;
|
||||||
use OCA\Deck\Db\Board;
|
use OCA\Deck\Db\Board;
|
||||||
use OCA\Deck\Db\BoardMapper;
|
use OCA\Deck\Db\BoardMapper;
|
||||||
use OCA\Deck\Db\CardMapper;
|
use OCA\Deck\Db\CardMapper;
|
||||||
@@ -44,8 +44,8 @@ class NotificationHelper {
|
|||||||
protected $cardMapper;
|
protected $cardMapper;
|
||||||
/** @var BoardMapper */
|
/** @var BoardMapper */
|
||||||
protected $boardMapper;
|
protected $boardMapper;
|
||||||
/** @var AssignedUsersMapper */
|
/** @var AssignmentMapper */
|
||||||
protected $assignedUsersMapper;
|
protected $assignmentMapper;
|
||||||
/** @var PermissionService */
|
/** @var PermissionService */
|
||||||
protected $permissionService;
|
protected $permissionService;
|
||||||
/** @var IConfig */
|
/** @var IConfig */
|
||||||
@@ -62,7 +62,7 @@ class NotificationHelper {
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
CardMapper $cardMapper,
|
CardMapper $cardMapper,
|
||||||
BoardMapper $boardMapper,
|
BoardMapper $boardMapper,
|
||||||
AssignedUsersMapper $assignedUsersMapper,
|
AssignmentMapper $assignmentMapper,
|
||||||
PermissionService $permissionService,
|
PermissionService $permissionService,
|
||||||
IConfig $config,
|
IConfig $config,
|
||||||
IManager $notificationManager,
|
IManager $notificationManager,
|
||||||
@@ -71,7 +71,7 @@ class NotificationHelper {
|
|||||||
) {
|
) {
|
||||||
$this->cardMapper = $cardMapper;
|
$this->cardMapper = $cardMapper;
|
||||||
$this->boardMapper = $boardMapper;
|
$this->boardMapper = $boardMapper;
|
||||||
$this->assignedUsersMapper = $assignedUsersMapper;
|
$this->assignmentMapper = $assignmentMapper;
|
||||||
$this->permissionService = $permissionService;
|
$this->permissionService = $permissionService;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->notificationManager = $notificationManager;
|
$this->notificationManager = $notificationManager;
|
||||||
@@ -107,7 +107,7 @@ class NotificationHelper {
|
|||||||
if ($user->getUID() === $board->getOwner() && count($board->getAcl()) === 0) {
|
if ($user->getUID() === $board->getOwner() && count($board->getAcl()) === 0) {
|
||||||
// Notify if all or assigned is configured for unshared boards
|
// Notify if all or assigned is configured for unshared boards
|
||||||
$shouldNotify = true;
|
$shouldNotify = true;
|
||||||
} elseif ($notificationSetting === ConfigService::SETTING_BOARD_NOTIFICATION_DUE_ASSIGNED && $this->assignedUsersMapper->isUserAssigned($card->getId(), $user->getUID())) {
|
} elseif ($notificationSetting === ConfigService::SETTING_BOARD_NOTIFICATION_DUE_ASSIGNED && $this->assignmentMapper->isUserAssigned($card->getId(), $user->getUID())) {
|
||||||
// Notify if the user is assigned and has the assigned setting selected
|
// Notify if the user is assigned and has the assigned setting selected
|
||||||
$shouldNotify = true;
|
$shouldNotify = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ class AssignmentMapperTest extends \Test\TestCase {
|
|||||||
$assignment = new Assignment();
|
$assignment = new Assignment();
|
||||||
$assignment->setCardId($this->cards[1]->getId());
|
$assignment->setCardId($this->cards[1]->getId());
|
||||||
$assignment->setParticipant('invalid-username');
|
$assignment->setParticipant('invalid-username');
|
||||||
$assignment->setType(AssignedUsers::TYPE_USER);
|
$assignment->setType(Assignment::TYPE_USER);
|
||||||
$this->expectException(NotFoundException::class);
|
$this->expectException(NotFoundException::class);
|
||||||
$this->assignedUsersMapper->insert($assignment);
|
$this->assignedUsersMapper->insert($assignment);
|
||||||
}
|
}
|
||||||
@@ -190,10 +190,10 @@ class AssignmentMapperTest extends \Test\TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testIsUserAssigned() {
|
public function testIsUserAssigned() {
|
||||||
$assignment = new AssignedUsers();
|
$assignment = new Assignment();
|
||||||
$assignment->setCardId($this->cards[1]->getId());
|
$assignment->setCardId($this->cards[1]->getId());
|
||||||
$assignment->setParticipant(self::TEST_USER4);
|
$assignment->setParticipant(self::TEST_USER4);
|
||||||
$assignment->setType(AssignedUsers::TYPE_USER);
|
$assignment->setType(Assignment::TYPE_USER);
|
||||||
$this->assertFalse($this->assignedUsersMapper->isUserAssigned($this->cards[1]->getId(), self::TEST_USER4));
|
$this->assertFalse($this->assignedUsersMapper->isUserAssigned($this->cards[1]->getId(), self::TEST_USER4));
|
||||||
|
|
||||||
$assignment = $this->assignedUsersMapper->insert($assignment);
|
$assignment = $this->assignedUsersMapper->insert($assignment);
|
||||||
@@ -205,10 +205,10 @@ class AssignmentMapperTest extends \Test\TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testIsUserAssignedGroup() {
|
public function testIsUserAssignedGroup() {
|
||||||
$assignment = new AssignedUsers();
|
$assignment = new Assignment();
|
||||||
$assignment->setCardId($this->cards[1]->getId());
|
$assignment->setCardId($this->cards[1]->getId());
|
||||||
$assignment->setParticipant('group');
|
$assignment->setParticipant('group');
|
||||||
$assignment->setType(AssignedUsers::TYPE_GROUP);
|
$assignment->setType(Assignment::TYPE_GROUP);
|
||||||
$this->assertFalse($this->assignedUsersMapper->isUserAssigned($this->cards[1]->getId(), self::TEST_USER1));
|
$this->assertFalse($this->assignedUsersMapper->isUserAssigned($this->cards[1]->getId(), self::TEST_USER1));
|
||||||
$this->assertFalse($this->assignedUsersMapper->isUserAssigned($this->cards[1]->getId(), self::TEST_USER2));
|
$this->assertFalse($this->assignedUsersMapper->isUserAssigned($this->cards[1]->getId(), self::TEST_USER2));
|
||||||
$this->assertFalse($this->assignedUsersMapper->isUserAssigned($this->cards[1]->getId(), self::TEST_USER3));
|
$this->assertFalse($this->assignedUsersMapper->isUserAssigned($this->cards[1]->getId(), self::TEST_USER3));
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class AssignmentServiceTest extends TestCase {
|
|||||||
public function testAssignUser() {
|
public function testAssignUser() {
|
||||||
$assignments = [];
|
$assignments = [];
|
||||||
$this->assignedUsersMapper->expects($this->once())
|
$this->assignedUsersMapper->expects($this->once())
|
||||||
->method('find')
|
->method('findAll')
|
||||||
->with(123)
|
->with(123)
|
||||||
->willReturn($assignments);
|
->willReturn($assignments);
|
||||||
$assignment = new Assignment();
|
$assignment = new Assignment();
|
||||||
@@ -145,7 +145,7 @@ class AssignmentServiceTest extends TestCase {
|
|||||||
$this->expectExceptionMessage('The user is not part of the board');
|
$this->expectExceptionMessage('The user is not part of the board');
|
||||||
$assignments = [];
|
$assignments = [];
|
||||||
$this->assignedUsersMapper->expects($this->once())
|
$this->assignedUsersMapper->expects($this->once())
|
||||||
->method('find')
|
->method('findAll')
|
||||||
->with(123)
|
->with(123)
|
||||||
->willReturn($assignments);
|
->willReturn($assignments);
|
||||||
$assignment = new Assignment();
|
$assignment = new Assignment();
|
||||||
@@ -176,7 +176,7 @@ class AssignmentServiceTest extends TestCase {
|
|||||||
$assignment
|
$assignment
|
||||||
];
|
];
|
||||||
$this->assignedUsersMapper->expects($this->once())
|
$this->assignedUsersMapper->expects($this->once())
|
||||||
->method('find')
|
->method('findAll')
|
||||||
->with(123)
|
->with(123)
|
||||||
->willReturn($assignments);
|
->willReturn($assignments);
|
||||||
$actual = $this->assignmentService->assignUser(123, 'admin');
|
$actual = $this->assignmentService->assignUser(123, 'admin');
|
||||||
@@ -192,7 +192,7 @@ class AssignmentServiceTest extends TestCase {
|
|||||||
$assignment
|
$assignment
|
||||||
];
|
];
|
||||||
$this->assignedUsersMapper->expects($this->once())
|
$this->assignedUsersMapper->expects($this->once())
|
||||||
->method('find')
|
->method('findAll')
|
||||||
->with(123)
|
->with(123)
|
||||||
->willReturn($assignments);
|
->willReturn($assignments);
|
||||||
$this->assignedUsersMapper->expects($this->once())
|
$this->assignedUsersMapper->expects($this->once())
|
||||||
@@ -213,7 +213,7 @@ class AssignmentServiceTest extends TestCase {
|
|||||||
$assignment
|
$assignment
|
||||||
];
|
];
|
||||||
$this->assignedUsersMapper->expects($this->once())
|
$this->assignedUsersMapper->expects($this->once())
|
||||||
->method('find')
|
->method('findAll')
|
||||||
->with(123)
|
->with(123)
|
||||||
->willReturn($assignments);
|
->willReturn($assignments);
|
||||||
$this->expectException(NotFoundException::class);
|
$this->expectException(NotFoundException::class);
|
||||||
|
|||||||
Reference in New Issue
Block a user