import { SUPPORT_ATTACHMENT_MAX_BYTES, SUPPORT_ATTACHMENT_MAX_PER_MESSAGE } from '@edr/types';
import { MulterOptions } from '@nestjs/platform-express/multer/interfaces/multer-options.interface';

/** Multipart field name carrying chat files. */
export const SUPPORT_ATTACHMENT_FIELD = 'attachments';

/**
 * Multer-level caps for the chat send routes.
 *
 * These duplicate `SupportService.assertSendable` on purpose and don't replace
 * it: Multer stops reading the socket once a part exceeds `fileSize`, so an
 * oversized upload is cut off mid-stream rather than buffered into memory and
 * rejected afterwards. The service check produces the readable error.
 */
export const supportAttachmentMulterOptions: MulterOptions = {
  limits: {
    fileSize: SUPPORT_ATTACHMENT_MAX_BYTES,
    files: SUPPORT_ATTACHMENT_MAX_PER_MESSAGE,
  },
};
