mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-10-01 01:25:45 -04:00
Compare commits
7 Commits
c31d647b45
...
8e968d160e
Author | SHA1 | Date | |
---|---|---|---|
|
8e968d160e | ||
|
243726b03c | ||
|
939d8c7ffb | ||
|
7ca064f24d | ||
|
5332b3fc9b | ||
|
27266f60ba | ||
|
4daa1ef5ac |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "uptime-kuma",
|
||||
"version": "1.23.13",
|
||||
"version": "1.23.14",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -42,7 +42,7 @@
|
||||
"build-docker-nightly-amd64": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:nightly-amd64 --target nightly . --push --progress plain",
|
||||
"build-docker-pr-test": "docker buildx build -f docker/dockerfile --platform linux/amd64,linux/arm64 -t louislam/uptime-kuma:pr-test --target pr-test . --push",
|
||||
"upload-artifacts": "docker buildx build -f docker/dockerfile --platform linux/amd64 -t louislam/uptime-kuma:upload-artifact --build-arg VERSION --build-arg GITHUB_TOKEN --target upload-artifact . --progress plain",
|
||||
"setup": "git checkout 1.23.13 && npm ci --production && npm run download-dist",
|
||||
"setup": "git checkout 1.23.14 && npm ci --production && npm run download-dist",
|
||||
"download-dist": "node extra/download-dist.js",
|
||||
"mark-as-nightly": "node extra/mark-as-nightly.js",
|
||||
"reset-password": "node extra/reset-password.js",
|
||||
|
@ -35,6 +35,21 @@ class Teams extends NotificationProvider {
|
||||
return "008cff";
|
||||
};
|
||||
|
||||
/**
|
||||
* Select the style to use based on status
|
||||
* @param {const} status The status constant
|
||||
* @returns {string} Selected style for adaptive cards
|
||||
*/
|
||||
_getStyle = (status) => {
|
||||
if (status === DOWN) {
|
||||
return "attention";
|
||||
}
|
||||
if (status === UP) {
|
||||
return "good";
|
||||
}
|
||||
return "emphasis";
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate payload for notification
|
||||
* @param {const} status The status of the monitor
|
||||
@ -49,48 +64,114 @@ class Teams extends NotificationProvider {
|
||||
monitorName,
|
||||
monitorUrl,
|
||||
}) => {
|
||||
const notificationMessage = this._statusMessageFactory(
|
||||
status,
|
||||
monitorName
|
||||
);
|
||||
|
||||
const facts = [];
|
||||
const actions = [];
|
||||
|
||||
if (monitorMessage) {
|
||||
facts.push({
|
||||
title: "Description",
|
||||
value: monitorMessage,
|
||||
});
|
||||
}
|
||||
|
||||
if (monitorName) {
|
||||
facts.push({
|
||||
name: "Monitor",
|
||||
title: "Monitor",
|
||||
value: monitorName,
|
||||
});
|
||||
}
|
||||
|
||||
if (monitorUrl && monitorUrl !== "https://") {
|
||||
facts.push({
|
||||
name: "URL",
|
||||
value: monitorUrl,
|
||||
title: "URL",
|
||||
// format URL as markdown syntax, to be clickable
|
||||
value: `[${monitorUrl}](${monitorUrl})`,
|
||||
});
|
||||
actions.push({
|
||||
"type": "Action.OpenUrl",
|
||||
"title": "Visit Monitor URL",
|
||||
"url": monitorUrl
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
"@context": "https://schema.org/extensions",
|
||||
"@type": "MessageCard",
|
||||
themeColor: this._getThemeColor(status),
|
||||
summary: notificationMessage,
|
||||
sections: [
|
||||
const payload = {
|
||||
"type": "message",
|
||||
// message with status prefix as notification text
|
||||
"summary": this._statusMessageFactory(status, monitorName),
|
||||
"attachments": [
|
||||
{
|
||||
activityImage:
|
||||
"https://raw.githubusercontent.com/louislam/uptime-kuma/master/public/icon.png",
|
||||
activityTitle: "**Uptime Kuma**",
|
||||
},
|
||||
{
|
||||
activityTitle: notificationMessage,
|
||||
},
|
||||
{
|
||||
activityTitle: "**Description**",
|
||||
text: monitorMessage,
|
||||
facts,
|
||||
},
|
||||
],
|
||||
"contentType": "application/vnd.microsoft.card.adaptive",
|
||||
"contentUrl": "",
|
||||
"content": {
|
||||
"type": "AdaptiveCard",
|
||||
"body": [
|
||||
{
|
||||
"type": "Container",
|
||||
"verticalContentAlignment": "Center",
|
||||
"items": [
|
||||
{
|
||||
"type": "ColumnSet",
|
||||
"style": this._getStyle(status),
|
||||
"columns": [
|
||||
{
|
||||
"type": "Column",
|
||||
"width": "auto",
|
||||
"verticalContentAlignment": "Center",
|
||||
"items": [
|
||||
{
|
||||
"type": "Image",
|
||||
"width": "32px",
|
||||
"style": "Person",
|
||||
"url": "https://raw.githubusercontent.com/louislam/uptime-kuma/master/public/icon.png",
|
||||
"altText": "Uptime Kuma Logo"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Column",
|
||||
"width": "stretch",
|
||||
"items": [
|
||||
{
|
||||
"type": "TextBlock",
|
||||
"size": "Medium",
|
||||
"weight": "Bolder",
|
||||
"text": `**${this._statusMessageFactory(status, monitorName, false)}**`,
|
||||
},
|
||||
{
|
||||
"type": "TextBlock",
|
||||
"size": "Small",
|
||||
"weight": "Default",
|
||||
"text": "Uptime Kuma Alert",
|
||||
"isSubtle": true,
|
||||
"spacing": "None"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "FactSet",
|
||||
"separator": false,
|
||||
"facts": facts
|
||||
}
|
||||
],
|
||||
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
|
||||
"version": "1.4"
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
if (actions) {
|
||||
payload.attachments[0].content.body.push({
|
||||
"type": "ActionSet",
|
||||
"actions": actions,
|
||||
});
|
||||
}
|
||||
|
||||
return payload;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -148,6 +229,7 @@ class Teams extends NotificationProvider {
|
||||
});
|
||||
|
||||
await this._sendNotification(notification.webhookUrl, payload);
|
||||
|
||||
return okMsg;
|
||||
} catch (error) {
|
||||
this.throwGeneralAxiosError(error);
|
||||
|
Loading…
Reference in New Issue
Block a user