pending filed added

master^2
Bhaskar 3 months ago
parent 8aaf894ba8
commit 5a12daeb6b

@ -9206,6 +9206,12 @@ exports.resolvedIssuesForSupport = async (req, reply) => {
}); });
} }
if (!["Escalation", "Pending"].includes(category)) {
return reply.code(400).send({
message: "Invalid category. Only 'Escalation' or 'Pending' are allowed",
});
}
const support = await Support.findOne({ supportId }); const support = await Support.findOne({ supportId });
if (!support) { if (!support) {
return reply.code(404).send({ message: "Support record not found" }); return reply.code(404).send({ message: "Support record not found" });
@ -9297,22 +9303,23 @@ exports.resolvedIssuesForSupport = async (req, reply) => {
support.resolvedIssues[resolvedIndex].invalidatedAt = nowTime; support.resolvedIssues[resolvedIndex].invalidatedAt = nowTime;
} }
// Move or update issue in categorizedIssues
if (categorizedIndex === -1) { if (categorizedIndex === -1) {
// Not in categorized — add with Escalation category // Not in categorized — add with category from body
support.categorizedIssues.push({ support.categorizedIssues.push({
type: issue.type, type: issue.type,
hardwareId: issue.hardwareId, hardwareId: issue.hardwareId,
masterHardwareId, masterHardwareId,
ticketId: issue.ticketId, ticketId: issue.ticketId,
category: "Escalation", category: category,
movedAt: nowTime, movedAt: nowTime,
movedToCategory: true, movedToCategory: true,
slaveName: issue.slaveName || null, slaveName: issue.slaveName || null,
}); });
} else { } else {
// Already in categorized — update if category not "Escalation" // Already in categorized — update if category has changed
if (support.categorizedIssues[categorizedIndex].category !== "Escalation") { if (support.categorizedIssues[categorizedIndex].category !== category) {
support.categorizedIssues[categorizedIndex].category = "Escalation"; support.categorizedIssues[categorizedIndex].category = category;
support.categorizedIssues[categorizedIndex].movedAt = nowTime; support.categorizedIssues[categorizedIndex].movedAt = nowTime;
support.categorizedIssues[categorizedIndex].movedToCategory = true; support.categorizedIssues[categorizedIndex].movedToCategory = true;
} }
@ -9320,7 +9327,7 @@ exports.resolvedIssuesForSupport = async (req, reply) => {
await support.save(); await support.save();
return reply.send({ return reply.send({
message: "Master or some slaves are disconnected. Issue moved/kept in escalation category.", message: `Master or some slaves are disconnected. Issue moved/kept in '${category}' category.`,
}); });
} }
} catch (err) { } catch (err) {
@ -9329,3 +9336,4 @@ exports.resolvedIssuesForSupport = async (req, reply) => {
} }
}; };

Loading…
Cancel
Save