-
Notifications
You must be signed in to change notification settings - Fork 4
/
rocketchat_pagerduty_incoming.js
48 lines (43 loc) · 1.27 KB
/
rocketchat_pagerduty_incoming.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
class Script {
process_incoming_request({ request }) {
// console is a global helper to improve debug
console.log(request.content);
var alertColor = "warning";
var condition = request.content.messages[0].incident;
var pdReceiver = ":rocket:"
if(request.content.messages[0].incident.status === "triggered"){ alertColor = "danger"; pdReceiver = condition.assignments[0].summary; }
else if (request.content.messages[0].incident.status === "resolved") { alertColor = "good"; pdReceiver = condition.assignments[0].summary; }
else { pdReceiver = condition.assignments[0].summary; }
return {
content:{
attachments: [{
title: condition.title,
pretext: condition.summary,
title_link: condition.html_url,
text: condition.description,
color: alertColor,
fields: [
{
title: "Assignee",
value: pdReceiver
},
{
title: "Status",
value: condition.status
},
{
title: "Urgency",
value: condition.urgency
}
]
}]
}
};
return {
error: {
success: false,
message: 'Error'
}
};
}
}