mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-17 15:19:50 -06:00
Add teamID to maintenance-window
This commit is contained in:
@@ -3,9 +3,9 @@ const {
|
||||
getMaintenanceWindowsByUserIdParamValidation,
|
||||
getMaintenanceWindowsByMonitorIdParamValidation,
|
||||
} = require("../validation/joi");
|
||||
|
||||
const jwt = require("jsonwebtoken");
|
||||
const { getTokenFromHeaders } = require("../utils/utils");
|
||||
const { successMessages } = require("../utils/messages");
|
||||
|
||||
const SERVICE_NAME = "maintenanceWindowController";
|
||||
|
||||
const createMaintenanceWindows = async (req, res, next) => {
|
||||
@@ -20,9 +20,13 @@ const createMaintenanceWindows = async (req, res, next) => {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const token = getTokenFromHeaders(req.headers);
|
||||
const { jwtSecret } = req.settingsService.getSettings();
|
||||
const { teamId } = jwt.verify(token, jwtSecret);
|
||||
const monitorIds = req.body.monitors;
|
||||
const dbTransactions = monitorIds.map((monitorId) => {
|
||||
return req.db.createMaintenanceWindow({
|
||||
teamId,
|
||||
monitorId,
|
||||
active: req.body.active ? req.body.active : true,
|
||||
repeat: req.body.repeat,
|
||||
|
||||
@@ -34,9 +34,9 @@ const MaintenanceWindow = mongoose.Schema(
|
||||
ref: "Monitor",
|
||||
immutable: true,
|
||||
},
|
||||
userId: {
|
||||
teamId: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: "User",
|
||||
ref: "Team",
|
||||
immutable: true,
|
||||
},
|
||||
active: {
|
||||
|
||||
@@ -364,7 +364,7 @@ const deletePageSpeedCheckParamValidation = joi.object({
|
||||
|
||||
const createMaintenanceWindowBodyValidation = joi.object({
|
||||
monitors: joi.array().items(joi.string()).required(),
|
||||
userId: joi.string().required(),
|
||||
teamId: joi.string().required(),
|
||||
active: joi.boolean(),
|
||||
start: joi.date().required(),
|
||||
end: joi.date().required(),
|
||||
|
||||
Reference in New Issue
Block a user