Added all community endpoints

This commit is contained in:
hannathkadher
2024-10-17 10:55:26 +04:00
parent b8d4a080ef
commit d6777c8ec1
17 changed files with 333 additions and 126 deletions
@@ -0,0 +1,33 @@
import { Injectable } from '@nestjs/common';
import { BadRequestException } from '@nestjs/common';
import { CommunityRepository } from '@app/common/modules/community/repositories';
@Injectable()
export class CommunityPermissionService {
constructor(private readonly communityRepository: CommunityRepository) {}
async checkUserPermission(
communityUuid: string,
userUuid: string,
): Promise<void> {
try {
const communityData = await this.communityRepository.findOne({
where: {
uuid: communityUuid,
users: {
uuid: userUuid,
},
},
relations: ['users'],
});
if (!communityData) {
throw new BadRequestException(
'You do not have permission to access this community',
);
}
} catch (err) {
throw new BadRequestException(err.message || 'Invalid UUID');
}
}
}