feat(notification): discord suppress notifications (#6717)
This commit is contained in:
parent
bb0c1b3723
commit
a85868ba7c
@ -11,6 +11,11 @@ class Discord extends NotificationProvider {
|
||||
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||||
const okMsg = "Sent Successfully.";
|
||||
|
||||
// Discord Message Flags
|
||||
// @see https://discord.com/developers/docs/resources/message#message-object-message-flags
|
||||
// This message will not trigger push and desktop notifications
|
||||
const SUPPRESS_NOTIFICATIONS_FLAG = 1 << 12;
|
||||
|
||||
try {
|
||||
let config = this.getAxiosConfigWithProxy({});
|
||||
const discordDisplayName = notification.discordUsername || "Uptime Kuma";
|
||||
@ -41,6 +46,9 @@ class Discord extends NotificationProvider {
|
||||
if (notification.discordChannelType === "createNewForumPost") {
|
||||
discordtestdata.thread_name = notification.postName;
|
||||
}
|
||||
if (notification.discordSuppressNotifications) {
|
||||
discordtestdata.flags = SUPPRESS_NOTIFICATIONS_FLAG;
|
||||
}
|
||||
await axios.post(webhookUrl.toString(), discordtestdata, config);
|
||||
return okMsg;
|
||||
}
|
||||
@ -89,6 +97,9 @@ class Discord extends NotificationProvider {
|
||||
if (notification.discordPrefixMessage) {
|
||||
discorddowndata.content = notification.discordPrefixMessage;
|
||||
}
|
||||
if (notification.discordSuppressNotifications) {
|
||||
discorddowndata.flags = SUPPRESS_NOTIFICATIONS_FLAG;
|
||||
}
|
||||
|
||||
await axios.post(webhookUrl.toString(), discorddowndata, config);
|
||||
return okMsg;
|
||||
@ -140,6 +151,9 @@ class Discord extends NotificationProvider {
|
||||
if (notification.discordPrefixMessage) {
|
||||
discordupdata.content = notification.discordPrefixMessage;
|
||||
}
|
||||
if (notification.discordSuppressNotifications) {
|
||||
discordupdata.flags = SUPPRESS_NOTIFICATIONS_FLAG;
|
||||
}
|
||||
|
||||
await axios.post(webhookUrl.toString(), discordupdata, config);
|
||||
return okMsg;
|
||||
|
||||
@ -102,6 +102,24 @@
|
||||
<label class="form-check-label" for="discord-disable-url">{{ $t("Disable URL in Notification") }}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="form-check form-switch">
|
||||
<input
|
||||
id="discord-suppress-notifications"
|
||||
v-model="$parent.notification.discordSuppressNotifications"
|
||||
class="form-check-input"
|
||||
type="checkbox"
|
||||
role="switch"
|
||||
/>
|
||||
<label class="form-check-label" for="discord-suppress-notifications">
|
||||
{{ $t("Suppress Notifications") }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-text">
|
||||
{{ $t("discordSuppressNotificationsHelptext") }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
@ -112,6 +130,9 @@ export default {
|
||||
if (this.$parent.notification.disableUrl === undefined) {
|
||||
this.$parent.notification.disableUrl = false;
|
||||
}
|
||||
if (this.$parent.notification.discordSuppressNotifications === undefined) {
|
||||
this.$parent.notification.discordSuppressNotifications = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -1265,6 +1265,8 @@
|
||||
"Matomo": "Matomo",
|
||||
"Umami": "Umami",
|
||||
"Disable URL in Notification": "Disable URL in Notification",
|
||||
"Suppress Notifications": "Suppress Notifications",
|
||||
"discordSuppressNotificationsHelptext": "When enabled, messages will be posted to the channel but won't trigger push or desktop notifications for recipients.",
|
||||
"Ip Family": "IP Family",
|
||||
"ipFamilyDescriptionAutoSelect": "Uses the {happyEyeballs} for determining the IP family.",
|
||||
"Happy Eyeballs algorithm": "Happy Eyeballs algorithm",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user