feat: add attachment upload with streaming and image validation

This commit is contained in:
2026-11-05 15:05:36 +03:00
parent d960734dae
commit fa0211eecb
20 changed files with 3252 additions and 15 deletions
+3 -11
View File
@@ -1,11 +1,11 @@
import { Injectable } from '@nestjs/common';
import { Prisma } from '@prisma/client';
import { createHash } from 'crypto';
import { assertChatMember } from '../chats/chat-access';
import { codePointLength } from '../common/dto/code-point-length.validator';
import { decodeMessageCursor, encodeMessageCursor } from '../common/cursor';
import { Message } from '../common/domain';
import { ApiError } from '../common/filters/api-error';
import { validate as isUuid } from '../common/uuid';
import { PrismaService } from '../db/prisma.service';
import { MessagePageResponse, toMessageResponse } from './dto/message.response';
@@ -125,16 +125,8 @@ export class MessagesService {
};
}
private async assertMember(chatId: string, callerId: string): Promise<void> {
if (!isUuid(chatId)) {
throw new ApiError('invalid_request', 'chatId must be a valid UUID');
}
const member = await this.prisma.chatMember.findUnique({
where: { chatId_userId: { chatId, userId: callerId } },
});
if (!member) {
throw new ApiError('not_found', 'chat not found');
}
private assertMember(chatId: string, callerId: string): Promise<void> {
return assertChatMember(this.prisma, chatId, callerId);
}
}