import { DataSource } from 'typeorm';
import { ReactionEntity } from '../../../entities';
import { RemoveReactionCommand } from '../../types';

export async function handleRemoveReaction(command: RemoveReactionCommand, dataSource: DataSource): Promise<void> {
  const repo = dataSource.getRepository(ReactionEntity);
  const { messageId, userId, emoji } = command.payload;

  await repo.delete({ messageId, userId, emoji });
}
