-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathGetAllNotificationsByUser.ts
More file actions
30 lines (28 loc) · 1.25 KB
/
GetAllNotificationsByUser.ts
File metadata and controls
30 lines (28 loc) · 1.25 KB
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
28
29
30
import { UseCase } from '../../../core/domain/useCases/UseCase'
import { INotificationsRepository } from '../repositories/INotificationsRepository'
import { NotificationSubset } from '../models/NotificationSubset'
export class GetAllNotificationsByUser implements UseCase<NotificationSubset> {
constructor(private readonly notificationsRepository: INotificationsRepository) {}
/**
* Use case for retrieving all notifications for the current user.
*
* @param inAppNotificationFormat - Optional parameter to retrieve fields needed for in-app notifications
* @param onlyUnread - Optional parameter to filter only unread notifications
* @param limit - Optional parameter to limit the number of notifications returned
* @param offset - Optional parameter to skip a number of notifications (for pagination)
* @returns {Promise<NotificationSubset>} - A promise that resolves to an array of Notification instances.
*/
async execute(
inAppNotificationFormat?: boolean,
onlyUnread?: boolean,
limit?: number,
offset?: number
): Promise<NotificationSubset> {
return (await this.notificationsRepository.getAllNotificationsByUser(
inAppNotificationFormat,
onlyUnread,
limit,
offset
)) as NotificationSubset
}
}