fix: slack rich notification not working correctly (#5209)

This commit is contained in:
Frank Elsinga 2024-10-16 16:50:41 +02:00 committed by GitHub
parent 42e77798e5
commit ed6087e233
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -32,7 +32,7 @@ class Slack extends NotificationProvider {
* @param {object} monitorJSON The monitor config * @param {object} monitorJSON The monitor config
* @returns {Array} The relevant action objects * @returns {Array} The relevant action objects
*/ */
static buildActions(baseURL, monitorJSON) { buildActions(baseURL, monitorJSON) {
const actions = []; const actions = [];
if (baseURL) { if (baseURL) {
@ -73,7 +73,7 @@ class Slack extends NotificationProvider {
* @param {string} msg The message body * @param {string} msg The message body
* @returns {Array<object>} The rich content blocks for the Slack message * @returns {Array<object>} The rich content blocks for the Slack message
*/ */
static buildBlocks(baseURL, monitorJSON, heartbeatJSON, title, msg) { buildBlocks(baseURL, monitorJSON, heartbeatJSON, title, msg) {
//create an array to dynamically add blocks //create an array to dynamically add blocks
const blocks = []; const blocks = [];
@ -150,7 +150,7 @@ class Slack extends NotificationProvider {
data.attachments.push( data.attachments.push(
{ {
"color": (heartbeatJSON["status"] === UP) ? "#2eb886" : "#e01e5a", "color": (heartbeatJSON["status"] === UP) ? "#2eb886" : "#e01e5a",
"blocks": Slack.buildBlocks(baseURL, monitorJSON, heartbeatJSON, title, msg), "blocks": this.buildBlocks(baseURL, monitorJSON, heartbeatJSON, title, msg),
} }
); );
} else { } else {