Files
gridpilot.gg/packages/notifications/application/use-cases/GetUnreadNotificationsUseCase.ts
2025-12-11 11:25:22 +01:00

33 lines
940 B
TypeScript

/**
* Application Use Case: GetUnreadNotificationsUseCase
*
* Retrieves unread notifications for a recipient.
*/
import type { Notification } from '../../domain/entities/Notification';
import type { INotificationRepository } from '../../domain/repositories/INotificationRepository';
export interface UnreadNotificationsResult {
notifications: Notification[];
totalCount: number;
}
export class GetUnreadNotificationsUseCase {
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.
*/