only allow for valid urls in slack button (#5312)
This commit is contained in:
parent
a7407a1b65
commit
13ea190298
|
@ -1,7 +1,7 @@
|
||||||
const NotificationProvider = require("./notification-provider");
|
const NotificationProvider = require("./notification-provider");
|
||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
const { setSettings, setting } = require("../util-server");
|
const { setSettings, setting } = require("../util-server");
|
||||||
const { getMonitorRelativeURL, UP } = require("../../src/util");
|
const { getMonitorRelativeURL, UP, log } = require("../../src/util");
|
||||||
|
|
||||||
class Slack extends NotificationProvider {
|
class Slack extends NotificationProvider {
|
||||||
name = "slack";
|
name = "slack";
|
||||||
|
@ -50,15 +50,20 @@ class Slack extends NotificationProvider {
|
||||||
|
|
||||||
const address = this.extractAddress(monitorJSON);
|
const address = this.extractAddress(monitorJSON);
|
||||||
if (address) {
|
if (address) {
|
||||||
actions.push({
|
try {
|
||||||
"type": "button",
|
actions.push({
|
||||||
"text": {
|
"type": "button",
|
||||||
"type": "plain_text",
|
"text": {
|
||||||
"text": "Visit site",
|
"type": "plain_text",
|
||||||
},
|
"text": "Visit site",
|
||||||
"value": "Site",
|
},
|
||||||
"url": address,
|
"value": "Site",
|
||||||
});
|
"url": new URL(address),
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
log.debug("slack", `Failed to parse address ${address} as URL`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return actions;
|
return actions;
|
||||||
|
|
Loading…
Reference in New Issue