mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 18:27:05 +00:00
Merge pull request #192 from SyncrowIOT/fix-project-validation-to-get-users
Add project existence check in getUsersByProject method
This commit is contained in:
@ -6,16 +6,25 @@ import { UserStatusEnum } from '@app/common/constants/user-status.enum';
|
||||
import { RoleType } from '@app/common/constants/role.type.enum';
|
||||
import { InviteUserRepository } from '@app/common/modules/Invite-user/repositiories';
|
||||
import { UserRepository } from '@app/common/modules/user/repositories';
|
||||
import { ProjectService } from './project.service';
|
||||
|
||||
@Injectable()
|
||||
export class ProjectUserService {
|
||||
constructor(
|
||||
private readonly inviteUserRepository: InviteUserRepository,
|
||||
private readonly userRepository: UserRepository,
|
||||
private readonly projectService: ProjectService,
|
||||
) {}
|
||||
|
||||
async getUsersByProject(uuid: string): Promise<BaseResponseDto> {
|
||||
try {
|
||||
const project = await this.projectService.getProject(uuid);
|
||||
if (!project) {
|
||||
throw new HttpException(
|
||||
`Project with ID ${uuid} not found`,
|
||||
HttpStatus.NOT_FOUND,
|
||||
);
|
||||
}
|
||||
// Fetch invited users
|
||||
const invitedUsers = await this.inviteUserRepository.find({
|
||||
where: { project: { uuid }, isActive: true },
|
||||
|
Reference in New Issue
Block a user