pull/3003/head
Louis Lam 2 years ago
parent a6acd065bb
commit 524cf7c607

@ -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");

@ -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 = ? for (const maintenanceID of maintenanceIDList) {
LEFT JOIN maintenance_timeslot let maintenance = UptimeKumaServer.getInstance().getMaintenance(maintenanceID);
ON maintenance_timeslot.maintenance_id = maintenance.id if (maintenance && await maintenance.isUnderMaintenance()) {
WHERE ${activeCondition} publicMaintenanceList.push(await maintenance.toPublicJSON());
ORDER BY maintenance.end_date }
`, [ statusPageId ]));
for (const bean of maintenanceBeanList) {
publicMaintenanceList.push(await bean.toPublicJSON());
} }
return publicMaintenanceList; return publicMaintenanceList;

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

Loading…
Cancel
Save