This repository has no description
886 B
22 lines
1import { CardAddedToLibraryEvent } from '../../../cards/domain/events/CardAddedToLibraryEvent';
2import { IEventHandler } from '../../../../shared/application/events/IEventSubscriber';
3import { Result } from '../../../../shared/core/Result';
4import { SyncAccountDataUseCase } from '../useCases/SyncAccountDataUseCase';
5
6export class CardAddedToLibraryEventHandler
7 implements IEventHandler<CardAddedToLibraryEvent>
8{
9 constructor(private syncAccountDataUseCase: SyncAccountDataUseCase) {}
10
11 async handle(event: CardAddedToLibraryEvent): Promise<Result<void>> {
12 console.log(
13 `[SYNC] Handling CardAddedToLibraryEvent for curator: ${event.curatorId.value}`,
14 );
15
16 // Pass the curator ID from the event to the sync use case
17 return this.syncAccountDataUseCase.execute({
18 curatorId: event.curatorId.value,
19 cardId: event.cardId.getStringValue(),
20 });
21 }
22}