Merge branch 'develop' into feat/incidents-clear

This commit is contained in:
Aryaman Sharma authored and GitHub committed 2025-06-25 14:20:15 +05:30
commit 5d20cf26ab
28 files changed
+2295 -1269

No files matched your search

+6 -1
View File
@@ -77,11 +77,16 @@ class InviteController {
name: firstname,
link: `${clientHost}/register/${inviteToken.token}`,
});
await this.emailService.sendEmail(
const result = await this.emailService.sendEmail(
req.body.email,
"Welcome to Uptime Monitor",
html
);
if (!result) {
return res.error({
msg: "Failed to send invite e-mail... Please verify your settings.",
});
}
} catch (error) {
logger.warn({
message: error.message,
+1 -1
View File
@@ -80,7 +80,7 @@ const getChecksByMonitor = async ({
// Match
const matchStage = {
monitorId: ObjectId.createFromHexString(monitorId),
monitorId: new ObjectId(monitorId),
...(typeof status !== "undefined" && { status }),
...(typeof ack !== "undefined" && ackStage),
...(dateRangeLookup[dateRange] && {
+1 -1
View File
@@ -19,7 +19,7 @@ const getMonitorsByTeamIdExecutionStats = async (req) => {
order = "asc";
}
// Build match stage
const matchStage = { teamId: ObjectId.createFromHexString(req.params.teamId) };
const matchStage = { teamId: new ObjectId(req.params.teamId) };
if (type !== undefined) {
matchStage.type = Array.isArray(type) ? { $in: type } : type;
}
+3 -5
View File
@@ -523,7 +523,7 @@ const getMonitorsByTeamId = async ({
order = "asc";
}
// Build match stage
const matchStage = { teamId: ObjectId.createFromHexString(teamId) };
const matchStage = { teamId: new ObjectId(teamId) };
if (type !== undefined) {
matchStage.type = Array.isArray(type) ? { $in: type } : type;
}
@@ -563,8 +563,7 @@ const getMonitorsByTeamId = async ({
const getMonitorsAndSummaryByTeamId = async ({ type, explain, teamId }) => {
try {
const parsedTeamId = ObjectId.createFromHexString(teamId);
const matchStage = { teamId: parsedTeamId };
const matchStage = { teamId: new ObjectId(teamId) };
if (type !== undefined) {
matchStage.type = Array.isArray(type) ? { $in: type } : type;
}
@@ -606,9 +605,8 @@ const getMonitorsWithChecksByTeamId = async ({
field = "name";
order = "asc";
}
const parsedTeamId = ObjectId.createFromHexString(teamId);
// Build match stage
const matchStage = { teamId: parsedTeamId };
const matchStage = { teamId: new ObjectId(teamId) };
if (type !== undefined) {
matchStage.type = Array.isArray(type) ? { $in: type } : type;
}
@@ -4,7 +4,7 @@ const buildUptimeDetailsPipeline = (monitorId, dates, dateString) => {
return [
{
$match: {
monitorId: ObjectId.createFromHexString(monitorId),
monitorId: new ObjectId(monitorId),
createdAt: { $gte: dates.start, $lte: dates.end },
},
},
@@ -407,6 +407,16 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
],
},
},
{ $unwind: "$checks" },
{ $sort: { "checks._id": 1 } },
{
$group: {
_id: "$_id",
checks: { $push: "$checks" },
aggregateData: { $first: "$aggregateData" },
upChecks: { $first: "$upChecks" },
},
},
{
$project: {
aggregateData: {
@@ -415,12 +425,7 @@ const buildHardwareDetailsPipeline = (monitor, dates, dateString) => {
upChecks: {
$arrayElemAt: ["$upChecks", 0],
},
checks: {
$sortArray: {
input: "$checks",
sortBy: { _id: 1 },
},
},
checks: 1,
},
},
];
@@ -734,7 +739,7 @@ const buildGetMonitorsByTeamIdPipeline = (req) => {
order = "asc";
}
// Build the match stage
const matchStage = { teamId: ObjectId.createFromHexString(req.params.teamId) };
const matchStage = { teamId: new ObjectId(req.params.teamId) };
if (type !== undefined) {
matchStage.type = Array.isArray(type) ? { $in: type } : type;
}
+4 -14
View File
@@ -134,6 +134,9 @@ const getStatusPage = async (url) => {
},
},
},
{ $match: { "monitors.orderIndex": { $ne: -1 } } },
{ $sort: { "monitors.orderIndex": 1 } },
{
$group: {
_id: "$_id",
@@ -156,20 +159,7 @@ const getStatusPage = async (url) => {
showAdminLoginLink: 1,
url: 1,
},
monitors: {
$filter: {
input: {
$sortArray: {
input: "$monitors",
sortBy: { orderIndex: 1 },
},
},
as: "monitor",
cond: {
$ne: ["$$monitor.orderIndex", -1],
},
},
},
monitors: 1,
},
},
]);
+11
View File
@@ -137,6 +137,17 @@ class EmailService {
};
this.transporter = this.nodemailer.createTransport(emailConfig);
try {
await this.transporter.verify();
} catch (error) {
this.logger.warn({
message: "Email transporter verification failed",
service: SERVICE_NAME,
method: "verifyTransporter",
});
return false;
}
try {
const info = await this.transporter.sendMail({
to: to,
+4 -4
View File
@@ -76,7 +76,7 @@ class Logger {
info(config) {
const logEntry = this.buildLogEntry("info", config);
this.cacheLog(logEntry);
this.logger.info(config.message, logEntry);
this.logger.info(logEntry);
}
/**
@@ -90,7 +90,7 @@ class Logger {
warn(config) {
const logEntry = this.buildLogEntry("warn", config);
this.cacheLog(logEntry);
this.logger.warn(config.message, logEntry);
this.logger.warn(logEntry);
}
/**
@@ -104,7 +104,7 @@ class Logger {
error(config) {
const logEntry = this.buildLogEntry("error", config);
this.cacheLog(logEntry);
this.logger.error(config.message, logEntry);
this.logger.error(logEntry);
}
/**
* Logs a debug message.
@@ -117,7 +117,7 @@ class Logger {
debug(config) {
const logEntry = this.buildLogEntry("debug", config);
this.cacheLog(logEntry);
this.logger.debug(config.message, logEntry);
this.logger.debug(logEntry);
}
cacheLog(entry) {