Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customisable Teams notifications #3192

Open
1 task done
iFusionFr opened this issue May 24, 2023 · 4 comments
Open
1 task done

Customisable Teams notifications #3192

iFusionFr opened this issue May 24, 2023 · 4 comments
Labels
area:notifications Everything related to notifications feature-request Request for new features to be added type:enhance-existing feature wants to enhance existing monitor

Comments

@iFusionFr
Copy link

iFusionFr commented May 24, 2023

⚠️ Please verify that this feature request has NOT been suggested before.

  • I checked and didn't find similar feature request

🏷️ Feature Request Type

UI Feature

🔖 Feature description

  • ability to put an image on a probe and have it show up when notifying on Teams.
  • ability to modify the text "Uptime Kuma" (next to the image) by a personalized text to the probe. (In my use case, my client's name).
    activityTitle: "**Uptime Kuma**",

✔️ Solution

❓ Alternatives

No response

📝 Additional Context

Edit (CommanderStorm): This issue was edited and features which are tracked in #456 were removed

Related #646

@iFusionFr iFusionFr added the feature-request Request for new features to be added label May 24, 2023
@CommanderStorm
Copy link
Collaborator

CommanderStorm commented May 24, 2023

What do you mean by Translation of Teams notifications. (In my case the French translation)?

If you are referring to imperfect french translations, please head over to https://github.com/louislam/uptime-kuma/blob/master/src/lang/README.md
Help in localisation from native speakers is always appreciated :)

Maybe you are also refering to #456

@iFusionFr

This comment was marked as off-topic.

@CommanderStorm CommanderStorm added the area:notifications Everything related to notifications label Dec 6, 2023
@nneul
Copy link

nneul commented Jan 25, 2024

Lumping this in to semi-related issue. Teams notifications are currently not showing useful information "above the fold". This is what I'm seeing in teams client:

image

Should at least get the first lines rolled together so that it displays information that is useful without having to expand the item:

image

@CommanderStorm CommanderStorm changed the title Improvements to Teams notifications Customisable Teams notifications Jan 25, 2024
@CommanderStorm CommanderStorm added the type:enhance-existing feature wants to enhance existing monitor label Jan 25, 2024
@CommanderStorm
Copy link
Collaborator

Here is our contribution guide:
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md

We rely on help with these providers, given that the core maintainer team is too slim for this level of detailed work.
The teams notification provider is located here:

const NotificationProvider = require("./notification-provider");
const axios = require("axios");
const { DOWN, UP } = require("../../src/util");
class Teams extends NotificationProvider {
name = "teams";
/**
* Generate the message to send
* @param {const} status The status constant
* @param {string} monitorName Name of monitor
* @returns {string}
*/
_statusMessageFactory = (status, monitorName) => {
if (status === DOWN) {
return `🔴 Application [${monitorName}] went down`;
} else if (status === UP) {
return `✅ Application [${monitorName}] is back online`;
}
return "Notification";
};
/**
* Select theme color to use based on status
* @param {const} status The status constant
* @returns {string} Selected color in hex RGB format
*/
_getThemeColor = (status) => {
if (status === DOWN) {
return "ff0000";
}
if (status === UP) {
return "00e804";
}
return "008cff";
};
/**
* 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}
*/
_notificationPayloadFactory = ({
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
* @param {string} webhookUrl URL to send the request to
* @param {Object} payload Payload generated by _notificationPayloadFactory
*/
_sendNotification = async (webhookUrl, payload) => {
await axios.post(webhookUrl, payload);
};
/**
* Send a general notification
* @param {string} webhookUrl URL to send request to
* @param {string} msg Message to send
* @returns {Promise<void>}
*/
_handleGeneralNotification = (webhookUrl, msg) => {
const payload = this._notificationPayloadFactory({
monitorMessage: msg
});
return this._sendNotification(webhookUrl, payload);
};
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully.";
try {
if (heartbeatJSON == null) {
await this._handleGeneralNotification(notification.webhookUrl, msg);
return okMsg;
}
let url;
switch (monitorJSON["type"]) {
case "http":
case "keywork":
url = monitorJSON["url"];
break;
case "docker":
url = monitorJSON["docker_host"];
break;
default:
url = monitorJSON["hostname"];
break;
}
const payload = this._notificationPayloadFactory({
monitorMessage: heartbeatJSON.msg,
monitorName: monitorJSON.name,
monitorUrl: url,
status: heartbeatJSON.status,
});
await this._sendNotification(notification.webhookUrl, payload);
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
}
module.exports = Teams;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:notifications Everything related to notifications feature-request Request for new features to be added type:enhance-existing feature wants to enhance existing monitor
Projects
None yet
Development

No branches or pull requests

3 participants