forked from olabiniV2/repo-notifications-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eventHandler_label.js
26 lines (23 loc) · 902 Bytes
/
eventHandler_label.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
const a = require('./eventAccessors.js');
module.exports = (e, {subjectFormatter: sf, messageFormatter: mf, escaper: esc}) => {
let subject = '';
let message = '';
switch(e.action) {
case 'created':
subject = `${sf.format_front(e, a)} created a new label: ${esc(e.label.name)}`;
message = `${mf.format_front(e, a)} created a new label: ${esc(e.label.name)}.`;
break;
case 'edited':
subject = `${sf.format_front(e, a)} changed the ${esc(e.label.name)} label`;
message = `${mf.format_front(e, a)} changed the ${esc(e.label.name)} label.`;
break;
case 'deleted':
subject = `${sf.format_front(e, a)} removed the ${esc(e.label.name)} label`;
message = `${mf.format_front(e, a)} removed the ${esc(e.label.name)} label.`;
break;
}
return {
subject: subject,
message: message,
};
};