mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-02-18 13:24:19 -05:00
Merge pull request #1 from tpai/fix/Teams-Workflow-Webhook
Fix and remove legacy code
This commit is contained in:
commit
939d8c7ffb
@ -94,17 +94,10 @@ class Teams extends NotificationProvider {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (heartbeatJSON?.localDateTime) {
|
|
||||||
// facts.push({
|
|
||||||
// title: "Time",
|
|
||||||
// value: heartbeatJSON.localDateTime + (heartbeatJSON.timezone ? ` (${heartbeatJSON.timezone})` : ""),
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
"type": "message",
|
"type": "message",
|
||||||
// message with status prefix as notification text
|
// message with status prefix as notification text
|
||||||
"summary": this._statusMessageFactory(status, monitorName, true),
|
"summary": this._statusMessageFactory(status, monitorName),
|
||||||
"attachments": [
|
"attachments": [
|
||||||
{
|
{
|
||||||
"contentType": "application/vnd.microsoft.card.adaptive",
|
"contentType": "application/vnd.microsoft.card.adaptive",
|
||||||
@ -181,64 +174,6 @@ class Teams extends NotificationProvider {
|
|||||||
return payload;
|
return payload;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate payload for notification
|
|
||||||
* @param {const} status The status of the monitor
|
|
||||||
* @param {string} monitorMessage Message to send
|
|
||||||
* @param {string} monitorName Name of monitor affected
|
|
||||||
* @param {string} monitorUrl URL of monitor affected
|
|
||||||
* @returns {Object}
|
|
||||||
*/
|
|
||||||
_notificationPayloadFactoryLegacy = ({
|
|
||||||
status,
|
|
||||||
monitorMessage,
|
|
||||||
monitorName,
|
|
||||||
monitorUrl,
|
|
||||||
}) => {
|
|
||||||
const notificationMessage = this._statusMessageFactory(
|
|
||||||
status,
|
|
||||||
monitorName
|
|
||||||
);
|
|
||||||
|
|
||||||
const facts = [];
|
|
||||||
|
|
||||||
if (monitorName) {
|
|
||||||
facts.push({
|
|
||||||
name: "Monitor",
|
|
||||||
value: monitorName,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (monitorUrl && monitorUrl !== "https://") {
|
|
||||||
facts.push({
|
|
||||||
name: "URL",
|
|
||||||
value: monitorUrl,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
"@context": "https://schema.org/extensions",
|
|
||||||
"@type": "MessageCard",
|
|
||||||
themeColor: this._getThemeColor(status),
|
|
||||||
summary: notificationMessage,
|
|
||||||
sections: [
|
|
||||||
{
|
|
||||||
activityImage:
|
|
||||||
"https://raw.githubusercontent.com/louislam/uptime-kuma/master/public/icon.png",
|
|
||||||
activityTitle: "**Uptime Kuma**",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
activityTitle: notificationMessage,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
activityTitle: "**Description**",
|
|
||||||
text: monitorMessage,
|
|
||||||
facts,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the notification
|
* Send the notification
|
||||||
* @param {string} webhookUrl URL to send the request to
|
* @param {string} webhookUrl URL to send the request to
|
||||||
@ -286,25 +221,14 @@ class Teams extends NotificationProvider {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notification.webhookUrl.includes("azure.com")) {
|
const payload = this._notificationPayloadFactory({
|
||||||
const payload = this._notificationPayloadFactory({
|
monitorMessage: heartbeatJSON.msg,
|
||||||
monitorMessage: heartbeatJSON.msg,
|
monitorName: monitorJSON.name,
|
||||||
monitorName: monitorJSON.name,
|
monitorUrl: url,
|
||||||
monitorUrl: url,
|
status: heartbeatJSON.status,
|
||||||
status: heartbeatJSON.status,
|
});
|
||||||
});
|
|
||||||
|
|
||||||
await this._sendNotification(notification.webhookUrl, payload);
|
await this._sendNotification(notification.webhookUrl, payload);
|
||||||
} else {
|
|
||||||
const payload = this._notificationPayloadFactoryLegacy({
|
|
||||||
monitorMessage: heartbeatJSON.msg,
|
|
||||||
monitorName: monitorJSON.name,
|
|
||||||
monitorUrl: url,
|
|
||||||
status: heartbeatJSON.status,
|
|
||||||
});
|
|
||||||
|
|
||||||
await this._sendNotification(notification.webhookUrl, payload);
|
|
||||||
}
|
|
||||||
|
|
||||||
return okMsg;
|
return okMsg;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user