This commit is contained in:
Louis Lam 2023-03-31 21:34:05 +08:00
parent a6acd065bb
commit 524cf7c607
3 changed files with 16 additions and 18 deletions

View File

@ -1,6 +1,5 @@
const { BeanModel } = require("redbean-node/dist/bean-model"); const { BeanModel } = require("redbean-node/dist/bean-model");
const { parseTimeObject, parseTimeFromTimeObject, utcToLocal, localToUTC, log } = require("../../src/util"); const { parseTimeObject, parseTimeFromTimeObject, log } = require("../../src/util");
const { timeObjectToUTC, timeObjectToLocal } = require("../util-server");
const { R } = require("redbean-node"); const { R } = require("redbean-node");
const dayjs = require("dayjs"); const dayjs = require("dayjs");
const Cron = require("croner"); const Cron = require("croner");

View File

@ -3,7 +3,6 @@ const { R } = require("redbean-node");
const cheerio = require("cheerio"); const cheerio = require("cheerio");
const { UptimeKumaServer } = require("../uptime-kuma-server"); const { UptimeKumaServer } = require("../uptime-kuma-server");
const jsesc = require("jsesc"); const jsesc = require("jsesc");
const Maintenance = require("./maintenance");
const googleAnalytics = require("../google-analytics"); const googleAnalytics = require("../google-analytics");
class StatusPage extends BeanModel { class StatusPage extends BeanModel {
@ -290,21 +289,17 @@ class StatusPage extends BeanModel {
try { try {
const publicMaintenanceList = []; const publicMaintenanceList = [];
let activeCondition = Maintenance.getActiveMaintenanceSQLCondition(); let maintenanceIDList = await R.getCol(`
let maintenanceBeanList = R.convertToBeans("maintenance", await R.getAll(` SELECT DISTINCT maintenance_id
SELECT DISTINCT maintenance.* FROM maintenance_status_page
FROM maintenance WHERE status_page_id = ?
JOIN maintenance_status_page `, [ statusPageId ]);
ON maintenance_status_page.maintenance_id = maintenance.id
AND maintenance_status_page.status_page_id = ?
LEFT JOIN maintenance_timeslot
ON maintenance_timeslot.maintenance_id = maintenance.id
WHERE ${activeCondition}
ORDER BY maintenance.end_date
`, [ statusPageId ]));
for (const bean of maintenanceBeanList) { for (const maintenanceID of maintenanceIDList) {
publicMaintenanceList.push(await bean.toPublicJSON()); let maintenance = UptimeKumaServer.getInstance().getMaintenance(maintenanceID);
if (maintenance && await maintenance.isUnderMaintenance()) {
publicMaintenanceList.push(await maintenance.toPublicJSON());
}
} }
return publicMaintenanceList; return publicMaintenanceList;

View File

@ -923,7 +923,11 @@ export default {
* @returns {string} Sanitized HTML * @returns {string} Sanitized HTML
*/ */
maintenanceHTML(description) { maintenanceHTML(description) {
return DOMPurify.sanitize(marked(description)); if (description) {
return DOMPurify.sanitize(marked(description));
} else {
return "";
}
}, },
} }