mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-05-29 01:42:34 +02:00
Add disable url
This commit is contained in:
parent
32d92eccfa
commit
5b20133eb4
5 changed files with 53 additions and 3 deletions
|
@ -0,0 +1,11 @@
|
|||
exports.up = function(knex) {
|
||||
return knex.schema.alterTable("notification", function(table) {
|
||||
table.boolean("disable_url").defaultTo(false).notNullable().comment("Disable URL in Discord notifications");
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = function(knex) {
|
||||
return knex.schema.alterTable("notification", function(table) {
|
||||
table.dropColumn("disable_url");
|
||||
});
|
||||
};
|
|
@ -48,7 +48,7 @@ class Discord extends NotificationProvider {
|
|||
},
|
||||
{
|
||||
name: monitorJSON["type"] === "push" ? "Service Type" : "Service URL",
|
||||
value: this.extractAddress(monitorJSON),
|
||||
value: notification.disableUrl ? "Hidden" : this.extractAddress(monitorJSON),
|
||||
},
|
||||
{
|
||||
name: `Time (${heartbeatJSON["timezone"]})`,
|
||||
|
@ -85,7 +85,7 @@ class Discord extends NotificationProvider {
|
|||
},
|
||||
{
|
||||
name: monitorJSON["type"] === "push" ? "Service Type" : "Service URL",
|
||||
value: this.extractAddress(monitorJSON),
|
||||
value: notification.disableUrl ? "Hidden" : this.extractAddress(monitorJSON),
|
||||
},
|
||||
{
|
||||
name: `Time (${heartbeatJSON["timezone"]})`,
|
||||
|
|
|
@ -313,6 +313,32 @@ let needSetup = false;
|
|||
const statusPageRouter = require("./routers/status-page-router");
|
||||
app.use(statusPageRouter);
|
||||
|
||||
// Update notification
|
||||
app.put("/notification/:id", async (req, res) => {
|
||||
try {
|
||||
await R.exec("UPDATE notification SET disableUrl = ? WHERE id = ?", [
|
||||
req.body.disableUrl || false,
|
||||
req.params.id,
|
||||
]);
|
||||
|
||||
res.status(200).send({ message: "Notification updated successfully" });
|
||||
} catch (error) {
|
||||
res.status(500).send({ error: "Failed to update notification" });
|
||||
}
|
||||
});
|
||||
|
||||
// Get notification
|
||||
app.get("/notification/:id", async (req, res) => {
|
||||
try {
|
||||
const notification = await R.findOne("notification", " id = ? ", [req.params.id]);
|
||||
res.json({
|
||||
disableUrl: notification.disableUrl,
|
||||
});
|
||||
} catch (error) {
|
||||
res.status(500).send({ error: "Failed to retrieve notification" });
|
||||
}
|
||||
});
|
||||
|
||||
// Universal Route Handler, must be at the end of all express routes.
|
||||
app.get("*", async (_request, response) => {
|
||||
if (_request.originalUrl.startsWith("/upload/")) {
|
||||
|
|
|
@ -53,6 +53,14 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="discord-disable-url" class="form-label">{{ $t("Disable URL in Notification") }}</label>
|
||||
<div class="form-check form-switch">
|
||||
<input id="discord-disable-url" v-model="$parent.notification.disableUrl" class="form-check-input" type="checkbox">
|
||||
<label class="form-check-label" for="discord-disable-url">{{ $t("Disable URL") }}</label>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
|
@ -60,6 +68,9 @@ export default {
|
|||
if (!this.$parent.notification.discordChannelType) {
|
||||
this.$parent.notification.discordChannelType = "channel";
|
||||
}
|
||||
if (this.$parent.notification.disableUrl === undefined) {
|
||||
this.$parent.notification.disableUrl = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -1093,5 +1093,7 @@
|
|||
"the smsplanet documentation": "the smsplanet documentation",
|
||||
"Phone numbers": "Phone numbers",
|
||||
"Sender name": "Sender name",
|
||||
"smsplanetNeedToApproveName": "Needs to be approved in the client panel"
|
||||
"smsplanetNeedToApproveName": "Needs to be approved in the client panel",
|
||||
"Disable URL in Notification": "Disable URL in Notification",
|
||||
"Disable URL": "Disable URL"
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue