import { DataSource } from 'typeorm';
import { AttachmentEntity } from '../../../entities';
import { DeleteAttachmentsForMessageCommand } from '../../types';

export async function handleDeleteAttachmentsForMessage(command: DeleteAttachmentsForMessageCommand, dataSource: DataSource): Promise<void> {
  const repo = dataSource.getRepository(AttachmentEntity);

  await repo.delete({ messageId: command.payload.messageId });
}
