Skip to content

Commit dafbd74

Browse files
committed
refactor(events): update assignee notification parameters for clarity and type safety
1 parent 83cf665 commit dafbd74

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

src/resolvers/helpers/bulkEventUtils.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { UserInputError } from 'apollo-server-express';
22
import { ObjectId } from 'mongodb';
33
import sendPersonalNotification from '../../utils/personalNotifications';
4-
import type { UserDBScheme } from '@hawk.so/types';
54
import { SenderWorkerTaskType } from '../../types/userNotifications/task-type';
5+
import type { EnqueueAssigneeNotificationParams } from '../../types/userNotifications/assignee';
66

77
/**
88
* Validate and normalize bulk event ids from resolver input.
@@ -24,14 +24,6 @@ export function parseBulkEventIds(eventIds: string[]): string[] {
2424
return uniqueEventIds;
2525
}
2626

27-
type AssigneeNotificationParams = {
28-
assigneeData: UserDBScheme | null;
29-
assigneeId: string;
30-
projectId: string;
31-
whoAssignedId: string;
32-
eventId: string;
33-
};
34-
3527
/**
3628
* Enqueue one assignee notification without blocking resolver response.
3729
*/
@@ -41,7 +33,7 @@ export function enqueueAssigneeNotification({
4133
projectId,
4234
whoAssignedId,
4335
eventId,
44-
}: AssigneeNotificationParams): void {
36+
}: EnqueueAssigneeNotificationParams): void {
4537
if (!assigneeData) {
4638
return;
4739
}

src/types/userNotifications/assignee.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { SenderWorkerTaskType } from './task-type';
22
import { SenderWorkerTask, SenderWorkerPayload } from './task';
3+
import type { UserDBScheme } from '@hawk.so/types';
34

45
/**
56
* Payload of the task to notify the user about the assignment to the task
@@ -31,4 +32,17 @@ export interface AssigneeNotificationPayload extends SenderWorkerPayload {
3132
*/
3233
export interface AssigneeNotificationTask extends SenderWorkerTask<AssigneeNotificationPayload> {
3334
type: SenderWorkerTaskType.Assignee;
34-
}
35+
}
36+
37+
/**
38+
* Params for enqueueing assignee notification from resolvers/helpers.
39+
*/
40+
export type EnqueueAssigneeNotificationParams = Pick<
41+
AssigneeNotificationPayload,
42+
'assigneeId' | 'projectId' | 'whoAssignedId' | 'eventId'
43+
> & {
44+
/**
45+
* Full user record of assignee.
46+
*/
47+
assigneeData: UserDBScheme | null;
48+
};

0 commit comments

Comments
 (0)