This commit is contained in:
Alex Holliday
2026-02-02 06:08:51 +00:00
parent 479f22ac69
commit 3a5783fe91
8 changed files with 27 additions and 9 deletions
@@ -171,7 +171,7 @@ export const CardDetails = ({ incident, monitor, sx }: CardDetailsProps) => {
</Typography>
</Grid>
<Grid size={10}>
<Typography>{incident.resolvedBy}</Typography>
<Typography>{incident.resolvedByEmail ?? incident.resolvedBy}</Typography>
</Grid>
</>
)}
+1
View File
@@ -9,6 +9,7 @@ export interface Incident {
statusCode?: number | null;
resolutionType: "automatic" | "manual" | null;
resolvedBy?: string | null;
resolvedByEmail?: string | null;
comment?: string | null;
createdAt: string;
updatedAt: string;
@@ -105,6 +105,12 @@ const requireUserId = (userId?: string): string => {
}
return userId;
};
const requireUserEmail = (userEmail?: string): string => {
if (!userEmail) {
throw new AppError({ message: "User email is required", status: 400 });
}
return userEmail;
};
export {
fetchMonitorCertificate,
@@ -116,4 +122,5 @@ export {
parseSortOrder,
requireTeamId,
requireUserId,
requireUserEmail,
};
+10 -7
View File
@@ -1,6 +1,6 @@
import { AppError } from "@/utils/AppError.js";
import { Request, Response, NextFunction } from "express";
import { requireTeamId } from "./controllerUtils.js";
import { requireTeamId, requireUserId, requireUserEmail } from "./controllerUtils.js";
const SERVICE_NAME = "incidentController";
@@ -86,12 +86,15 @@ class IncidentController {
resolveIncidentManually = async (req: Request, res: Response, next: NextFunction) => {
try {
const resolvedIncident = await this.incidentService.resolveIncident(
req?.params?.incidentId,
req?.user?.id,
req?.user?.teamId,
req?.body?.comment
);
const teamId = requireTeamId(req.user?.teamId);
const userId = requireUserId(req.user?.id);
const userEmail = requireUserEmail(req.user?.email);
const incidentId = req.params?.incidentId;
if (!incidentId) {
throw new AppError({ message: "Incident ID is required", service: SERVICE_NAME, status: 400 });
}
const resolvedIncident = await this.incidentService.resolveIncident(incidentId, userId, teamId, req?.body?.comment, userEmail);
return res.status(200).json({
success: true,
+4
View File
@@ -64,6 +64,10 @@ const IncidentSchema = new Schema<IncidentDocument>(
ref: "User",
default: null,
},
resolvedByEmail: {
type: String,
default: null,
},
comment: {
type: String,
default: null,
@@ -58,6 +58,7 @@ class MongoIncidentRepository implements IIncidentsRepository {
statusCode: doc.statusCode ?? null,
resolutionType: doc.resolutionType ?? null,
resolvedBy: doc.resolvedBy ? this.toStringId(doc.resolvedBy) : null,
resolvedByEmail: doc.resolvedByEmail ?? null,
comment: doc.comment ?? null,
createdAt: this.toDateString(doc.createdAt),
updatedAt: this.toDateString(doc.updatedAt),
@@ -71,7 +71,7 @@ class IncidentService {
return await this.incidentsRepository.updateById(activeIncident.id, activeIncident.teamId, activeIncident);
};
resolveIncident = async (incidentId: string, userId: string, teamId: string, comment?: string) => {
resolveIncident = async (incidentId: string, userId: string, teamId: string, comment?: string, userEmail?: string) => {
try {
if (!incidentId) {
throw new AppError({ message: "No incident ID in request", service: SERVICE_NAME, method: "resolveIncident" });
@@ -98,6 +98,7 @@ class IncidentService {
incident.resolutionType = "manual";
incident.status = false;
incident.resolvedBy = userId;
incident.resolvedByEmail = userEmail || null;
incident.comment = comment || null;
incident.endTime = Date.now().toString();
+1
View File
@@ -14,6 +14,7 @@ export interface Incident {
statusCode?: number | null;
resolutionType: IncidentResolutionType;
resolvedBy?: string | null;
resolvedByEmail?: string | null;
comment?: string | null;
createdAt: string;
updatedAt: string;