forked from olabiniV2/repo-notifications-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eventHandler_milestone.js
34 lines (31 loc) · 1.73 KB
/
eventHandler_milestone.js
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
const a = require('./eventAccessors.js');
module.exports = (e, {subjectFormatter: sf, messageFormatter: mf}) => {
let subject = '';
let message = '';
switch(e.action) {
case 'created':
subject = `${sf.format_front(e, a)} created a new milestone: ${sf.format_link_simple(e.milestone.html_url, e.milestone.title)}`;
message = `${mf.format_front(e, a)} created a new milestone: ${mf.format_link_simple(e.milestone.html_url, e.milestone.title)}.`;
break;
case 'closed':
subject = `${sf.format_front(e, a)} closed a milestone: ${sf.format_link_simple(e.milestone.html_url, e.milestone.title)}`;
message = `${mf.format_front(e, a)} closed a milestone: ${mf.format_link_simple(e.milestone.html_url, e.milestone.title)}.`;
break;
case 'opened':
subject = `${sf.format_front(e, a)} opened a milestone: ${sf.format_link_simple(e.milestone.html_url, e.milestone.title)}`;
message = `${mf.format_front(e, a)} opened a milestone: ${mf.format_link_simple(e.milestone.html_url, e.milestone.title)}.`;
break;
case 'edited':
subject = `${sf.format_front(e, a)} changed a milestone: ${sf.format_link_simple(e.milestone.html_url, e.milestone.title)}`;
message = `${mf.format_front(e, a)} changed a milestone: ${mf.format_link_simple(e.milestone.html_url, e.milestone.title)}.`;
break;
case 'deleted':
subject = `${sf.format_front(e, a)} removed a milestone: ${sf.format_link_simple(e.milestone.html_url, e.milestone.title)}`;
message = `${mf.format_front(e, a)} removed a milestone: ${mf.format_link_simple(e.milestone.html_url, e.milestone.title)}.`;
break;
}
return {
subject: subject,
message: message,
};
};