All files / application/eventHandlers TaskReopenedEventHandler.ts

100% Statements 11/11
100% Branches 2/2
100% Functions 3/3
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27          3x   2x   2x 2x 2x 2x   2x 2x       2x       2x      
import { DomainEvent } from '../../domain/events/DomainEvent';
import { TaskReopenedEvent } from '../../domain/events/TaskReopenedEvent';
 
export class TaskReopenedEventHandler {
  async handle(event: DomainEvent): Promise<void> {
    if (event.eventType !== 'TaskReopened') return;
 
    const taskReopenedEvent = event as TaskReopenedEvent;
 
    console.log('🔄 Task Reopened Event Triggered!');
    console.log(`Task ID: ${taskReopenedEvent.taskId.toString()}`);
    console.log(`Reopened by: ${taskReopenedEvent.reopenedBy.toString()}`);
    console.log(`Reopened at: ${taskReopenedEvent.reopenedAt.toISOString()}`);
 
    await this.sendNotification(taskReopenedEvent);
    await this.trackReopen(taskReopenedEvent);
  }
 
  private async sendNotification(event: TaskReopenedEvent): Promise<void> {
    console.log(`📧 Sending notification: Task reopened by user ${event.reopenedBy.toString()}`);
  }
 
  private async trackReopen(event: TaskReopenedEvent): Promise<void> {
    console.log(`📊 Analytics: Task reopen recorded`);
  }
}