| Total Complexity | 2 |
| Complexity/F | 2 |
| Lines of Code | 23 |
| Function Count | 1 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { Inject } from '@nestjs/common'; |
||
| 2 | import { ISchoolUserRepository } from 'src/Domain/School/Repository/ISchoolUserRepository'; |
||
| 3 | import { SchoolUser } from 'src/Domain/School/SchoolUser.entity'; |
||
| 4 | import { School } from '../../School/School.entity'; |
||
| 5 | import { User, UserRole } from '../User.entity'; |
||
| 6 | |||
| 7 | export class IsUserAlreadyAddedToSchool { |
||
| 8 | constructor( |
||
| 9 | @Inject('ISchoolUserRepository') |
||
| 10 | private readonly schoolUserRepository: ISchoolUserRepository |
||
| 11 | ) {} |
||
| 12 | |||
| 13 | public async isSatisfiedBy(school: School, user: User): Promise<boolean> { |
||
| 14 | if (user.getRole() === UserRole.PHOTOGRAPHER) { |
||
| 15 | return true; |
||
| 16 | } |
||
| 17 | |||
| 18 | return ( |
||
| 19 | (await this.schoolUserRepository.findOneByUserAndSchool(user, school)) instanceof SchoolUser |
||
| 20 | ); |
||
| 21 | } |
||
| 22 | } |
||
| 23 |