fix: leave house managers who are also team admins or travel managers out of house manager mail
This commit is contained in:
1 parent
f22d1f1199
commit
50ef662dd3
3 files changed
+29
-1
No files matched your search
@@ -126,6 +126,9 @@ class UserRepository extends ServiceEntityRepository
|
|||||||
* to them (a blocked account cannot log in to do what it is reminded of) and an assignment
|
* to them (a blocked account cannot log in to do what it is reminded of) and an assignment
|
||||||
* mailing puts them in CC. Hotel codes and muted notifications are the caller's to check.
|
* mailing puts them in CC. Hotel codes and muted notifications are the caller's to check.
|
||||||
*
|
*
|
||||||
|
* Left out is a house manager who is also a team admin or travel manager: staff hold the role
|
||||||
|
* and hotel codes for testing, and BusPro syncs both on every login, so they cannot be removed.
|
||||||
|
*
|
||||||
* @return User[]
|
* @return User[]
|
||||||
*/
|
*/
|
||||||
public function findActiveHouseManagers(): array
|
public function findActiveHouseManagers(): array
|
||||||
@@ -134,9 +137,13 @@ class UserRepository extends ServiceEntityRepository
|
|||||||
|
|
||||||
return $qb
|
return $qb
|
||||||
->where('JSON_CONTAINS(user.roles, :role) = 1')
|
->where('JSON_CONTAINS(user.roles, :role) = 1')
|
||||||
|
->andWhere('JSON_CONTAINS(user.roles, :teamAdmin) = 0')
|
||||||
|
->andWhere('JSON_CONTAINS(user.roles, :manager) = 0')
|
||||||
->andWhere($qb->expr()->isNull('user.deletedAt'))
|
->andWhere($qb->expr()->isNull('user.deletedAt'))
|
||||||
->andWhere($qb->expr()->isNull('user.disabledAt'))
|
->andWhere($qb->expr()->isNull('user.disabledAt'))
|
||||||
->setParameter('role', json_encode('ROLE_HOUSE_MANAGER'))
|
->setParameter('role', json_encode('ROLE_HOUSE_MANAGER'))
|
||||||
|
->setParameter('teamAdmin', json_encode('ROLE_TEAM_ADMIN'))
|
||||||
|
->setParameter('manager', json_encode('ROLE_MANAGER'))
|
||||||
->orderBy('user.id')
|
->orderBy('user.id')
|
||||||
->getQuery()
|
->getQuery()
|
||||||
->getResult()
|
->getResult()
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ class AssignmentMailingService
|
|||||||
* rule that gives them access to the house's teamers) is in CC on exactly one mail: that of
|
* rule that gives them access to the house's teamers) is in CC on exactly one mail: that of
|
||||||
* the first recipient confirmed on an assignment of their house, in the recipients' order.
|
* the first recipient confirmed on an assignment of their house, in the recipients' order.
|
||||||
* Muted notifications do not count, this is no notification. Left out is a house manager who
|
* Muted notifications do not count, this is no notification. Left out is a house manager who
|
||||||
* gets the mailing anyway, as one of the teamers or under one of their addresses.
|
* gets the mailing anyway, as one of the teamers or under one of their addresses, and a test
|
||||||
|
* account, see UserRepository::findActiveHouseManagers().
|
||||||
*
|
*
|
||||||
* @return array<int, User[]> teamer id => house managers
|
* @return array<int, User[]> teamer id => house managers
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -80,6 +80,26 @@ class HouseManagerReminderQueryTest extends KernelTestCase
|
|||||||
$this->assertNotContains($deleted, $reminded);
|
$this->assertNotContains($deleted, $reminded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Staff hold the house manager role and hotel codes for testing; a teamer who also runs a
|
||||||
|
* house is a real house manager.
|
||||||
|
*/
|
||||||
|
public function testHouseManagersWhoAreAlsoAdminsOrManagersAreLeftOut(): void
|
||||||
|
{
|
||||||
|
$teamer = $this->houseManager('[email protected]')->setRoles(['ROLE_HOUSE_MANAGER', 'ROLE_TEAMER']);
|
||||||
|
$admin = $this->houseManager('[email protected]')->setRoles(['ROLE_HOUSE_MANAGER', 'ROLE_TEAM_ADMIN']);
|
||||||
|
$manager = $this->houseManager('[email protected]')->setRoles(['ROLE_MANAGER', 'ROLE_HOUSE_MANAGER']);
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
/** @var UserRepository $repository */
|
||||||
|
$repository = $this->entityManager->getRepository(User::class);
|
||||||
|
$houseManagers = $repository->findActiveHouseManagers();
|
||||||
|
|
||||||
|
$this->assertContains($teamer, $houseManagers);
|
||||||
|
$this->assertNotContains($admin, $houseManagers);
|
||||||
|
$this->assertNotContains($manager, $houseManagers);
|
||||||
|
}
|
||||||
|
|
||||||
private function houseManager(string $email): User
|
private function houseManager(string $email): User
|
||||||
{
|
{
|
||||||
$teamer = (new Teamer())->setFirstName('Hanna')->setLastName('Haus')->setGender('d');
|
$teamer = (new Teamer())->setFirstName('Hanna')->setLastName('Haus')->setGender('d');
|
||||||
|
|||||||
Reference in new issue
Block a user