forked from BCDevOps/backup-container
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rocket.chat.integration.js
50 lines (45 loc) · 1.12 KB
/
rocket.chat.integration.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
49
50
class Script {
/**
* @params {object} request
*/
process_incoming_request({ request }) {
let data = request.content;
let attachmentColor = `#36A64F`;
let statusMsg = `Status`;
let isError = data.statusCode === `ERROR`;
if (isError) {
statusMsg = `Error`;
attachmentColor = `#A63636`;
}
let friendlyProjectName=``;
if(data.projectFriendlyName) {
friendlyProjectName = data.projectFriendlyName
}
let projectName=``;
if (data.projectName) {
projectName = data.projectName
if(!friendlyProjectName) {
friendlyProjectName = projectName
}
}
if(projectName) {
statusMsg += ` message received from [${friendlyProjectName}](https://console.pathfinder.gov.bc.ca:8443/console/project/${projectName}/overview):`;
} else {
statusMsg += ` message received:`;
}
if (isError) {
statusMsg = `**${statusMsg}**`;
}
return {
content:{
text: statusMsg,
attachments: [
{
text: `${data.message}`,
color: attachmentColor
}
]
}
};
}
}