3120 remove URL's from data when they are supposed to be disabled

This commit is contained in:
Craig Lawson committed 2026-01-10 12:15:29 +00:00
1 parent 5c14c68899
commit fb3795bd70
2 files changed
+13 -8

No files matched your search

+12 -7
View File
@@ -1,4 +1,3 @@
// import StatusPage from "../../models/StatusPage.js";
// import { NormalizeData } from "../../../utils/dataUtils.js";
// import ServiceRegistry from "../../../service/system/serviceRegistry.js";
// import StringService from "../../../service/system/stringService.js";
@@ -6,10 +5,11 @@
const SERVICE_NAME = "statusPageModule";
class StatusPageModule {
constructor({ StatusPage, NormalizeData, stringService }) {
constructor({ StatusPage, NormalizeData, stringService, AppSettings }) {
this.StatusPage = StatusPage;
this.NormalizeData = NormalizeData;
this.stringService = stringService;
this.AppSettings = AppSettings;
}
createStatusPage = async ({ statusPageData, image, userId, teamId }) => {
@@ -217,7 +217,7 @@ class StatusPageModule {
showUptimePercentage: 1,
timezone: 1,
showAdminLoginLink: 1,
url: 1,
url: { $cond: [{ $eq: ["$statusPage.showMonitorUrl", true] }, "$monitors.url", "$$REMOVE"] },
},
monitors: {
_id: 1,
@@ -260,11 +260,16 @@ class StatusPageModule {
const { statusPage, monitors } = statusPageQuery[0];
const appSettings = await this.AppSettings.findOne({ singleton: true }).lean();
const showURL = appSettings?.showURL === true;
const normalizedMonitors = monitors.map((monitor) => {
return {
...monitor,
checks: this.NormalizeData(monitor.checks, 10, 100),
};
const normalizedChecks = this.NormalizeData(monitor.checks, 10, 100);
if (showURL !== true) {
const { url, ...rest } = monitor;
return { ...rest, checks: normalizedChecks };
}
return { ...monitor, checks: normalizedChecks };
});
return { statusPage, monitors: normalizedMonitors };