34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
/**
|
|
* Application Use Case: GetUnreadNotificationsUseCase
|
|
*
|
|
* Retrieves unread notifications for a recipient.
|
|
*/
|
|
|
|
import type { AsyncUseCase } from '@gridpilot/shared/application';
|
|
import type { Notification } from '../../domain/entities/Notification';
|
|
import type { INotificationRepository } from '../../domain/repositories/INotificationRepository';
|
|
|
|
export interface UnreadNotificationsResult {
|
|
notifications: Notification[];
|
|
totalCount: number;
|
|
}
|
|
|
|
export class GetUnreadNotificationsUseCase implements AsyncUseCase<string, UnreadNotificationsResult> {
|
|
constructor(
|
|
private readonly notificationRepository: INotificationRepository,
|
|
) {}
|
|
|
|
async execute(recipientId: string): Promise<UnreadNotificationsResult> {
|
|
const notifications = await this.notificationRepository.findUnreadByRecipientId(recipientId);
|
|
|
|
return {
|
|
notifications,
|
|
totalCount: notifications.length,
|
|
};
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Additional notification query/use case types (e.g., listing or counting notifications)
|
|
* can be added here in the future as needed.
|
|
*/ |