import { ApiError } from '../common/filters/api-error'; import { validate as isUuid } from '../common/uuid'; import { PrismaService } from '../db/prisma.service'; export async function assertChatMember( prisma: PrismaService, chatId: string, userId: string, ): Promise { if (!isUuid(chatId)) { throw new ApiError('invalid_request', 'chatId must be a valid UUID'); } const member = await prisma.chatMember.findUnique({ where: { chatId_userId: { chatId, userId } }, }); if (!member) { throw new ApiError('not_found', 'chat not found'); } }