-
Notifications
You must be signed in to change notification settings - Fork 286
Expand file tree
/
Copy pathindex.ts
More file actions
61 lines (58 loc) · 1.98 KB
/
index.ts
File metadata and controls
61 lines (58 loc) · 1.98 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import type { GitifyNotification } from '../../../types';
import type { NotificationTypeHandler } from './types';
import { checkSuiteHandler } from './checkSuite';
import { commitHandler } from './commit';
import { defaultHandler } from './default';
import { discussionHandler } from './discussion';
import { issueHandler } from './issue';
import { pullRequestHandler } from './pullRequest';
import { releaseHandler } from './release';
import { repositoryAdvisoryHandler } from './repositoryAdvisory';
import { repositoryDependabotAlertsThreadHandler } from './repositoryDependabotAlertsThread';
import { repositoryInvitationHandler } from './repositoryInvitation';
import { repositoryVulnerabilityAlertHandler } from './repositoryVulnerabilityAlert';
import { workflowRunHandler } from './workflowRun';
export function createNotificationHandler(
notification: GitifyNotification,
): NotificationTypeHandler {
switch (notification.subject.type) {
case 'CheckSuite':
return checkSuiteHandler;
case 'Commit':
return commitHandler;
case 'Discussion':
return discussionHandler;
case 'Issue':
return issueHandler;
case 'PullRequest':
return pullRequestHandler;
case 'Release':
return releaseHandler;
case 'RepositoryAdvisory':
return repositoryAdvisoryHandler;
case 'RepositoryDependabotAlertsThread':
return repositoryDependabotAlertsThreadHandler;
case 'RepositoryInvitation':
return repositoryInvitationHandler;
case 'RepositoryVulnerabilityAlert':
return repositoryVulnerabilityAlertHandler;
case 'WorkflowRun':
return workflowRunHandler;
default:
return defaultHandler;
}
}
export const handlers = {
checkSuiteHandler,
commitHandler,
discussionHandler,
issueHandler,
pullRequestHandler,
releaseHandler,
repositoryAdvisoryHandler,
repositoryDependabotAlertsThreadHandler,
repositoryInvitationHandler,
repositoryVulnerabilityAlertHandler,
workflowRunHandler,
defaultHandler,
};