wip
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import type { AsyncUseCase } from '@gridpilot/shared/application';
|
||||
import type { ILogger } from '../../../shared/src/logging/ILogger';
|
||||
import { Notification } from '../../domain/entities/Notification';
|
||||
import type { NotificationData } from '../../domain/entities/Notification';
|
||||
import type { INotificationRepository } from '../../domain/repositories/INotificationRepository';
|
||||
@@ -48,11 +49,17 @@ export class SendNotificationUseCase implements AsyncUseCase<SendNotificationCom
|
||||
private readonly notificationRepository: INotificationRepository,
|
||||
private readonly preferenceRepository: INotificationPreferenceRepository,
|
||||
private readonly gatewayRegistry: INotificationGatewayRegistry,
|
||||
) {}
|
||||
private readonly logger: ILogger,
|
||||
) {
|
||||
this.logger.debug('SendNotificationUseCase initialized.');
|
||||
}
|
||||
|
||||
async execute(command: SendNotificationCommand): Promise<SendNotificationResult> {
|
||||
// Get recipient's preferences
|
||||
const preferences = await this.preferenceRepository.getOrCreateDefault(command.recipientId);
|
||||
this.logger.debug('Executing SendNotificationUseCase', { command });
|
||||
try {
|
||||
// Get recipient's preferences
|
||||
this.logger.debug('Checking notification preferences.', { type: command.type, recipientId: command.recipientId });
|
||||
const preferences = await this.preferenceRepository.getOrCreateDefault(command.recipientId);
|
||||
|
||||
// Check if this notification type is enabled
|
||||
if (!preferences.isTypeEnabled(command.type)) {
|
||||
|
||||
Reference in New Issue
Block a user