mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-17 03:05:13 +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 { RoleType } from '@app/common/constants/role.type.enum';
|
||||||
import { InviteUserRepository } from '@app/common/modules/Invite-user/repositiories';
|
import { InviteUserRepository } from '@app/common/modules/Invite-user/repositiories';
|
||||||
import { UserRepository } from '@app/common/modules/user/repositories';
|
import { UserRepository } from '@app/common/modules/user/repositories';
|
||||||
|
import { ProjectService } from './project.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ProjectUserService {
|
export class ProjectUserService {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly inviteUserRepository: InviteUserRepository,
|
private readonly inviteUserRepository: InviteUserRepository,
|
||||||
private readonly userRepository: UserRepository,
|
private readonly userRepository: UserRepository,
|
||||||
|
private readonly projectService: ProjectService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async getUsersByProject(uuid: string): Promise<BaseResponseDto> {
|
async getUsersByProject(uuid: string): Promise<BaseResponseDto> {
|
||||||
try {
|
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
|
// Fetch invited users
|
||||||
const invitedUsers = await this.inviteUserRepository.find({
|
const invitedUsers = await this.inviteUserRepository.find({
|
||||||
where: { project: { uuid }, isActive: true },
|
where: { project: { uuid }, isActive: true },
|
||||||
|
Reference in New Issue
Block a user