forked from Yara724/api
YARA-1162
This commit is contained in:
@@ -9373,16 +9373,26 @@ export class RequestManagementService {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (typeof (req as any).markModified === "function") {
|
||||||
|
(req as any).markModified("expert");
|
||||||
|
}
|
||||||
|
|
||||||
if (!Array.isArray(req.history)) req.history = [];
|
if (!Array.isArray(req.history)) req.history = [];
|
||||||
req.history.push({
|
// Avoid duplicate history entries on idempotent retries.
|
||||||
type: "V3_ACCIDENT_FIELDS_SAVED",
|
const alreadyRecorded = (req.history as any[]).some(
|
||||||
actor: {
|
(e: any) => e?.type === "V3_ACCIDENT_FIELDS_SAVED",
|
||||||
actorId: new Types.ObjectId(String(expert.sub)),
|
);
|
||||||
actorName: `${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
if (!alreadyRecorded) {
|
||||||
actorType: "field_expert",
|
req.history.push({
|
||||||
},
|
type: "V3_ACCIDENT_FIELDS_SAVED",
|
||||||
metadata: { accidentWay: fields.accidentWay },
|
actor: {
|
||||||
} as any);
|
actorId: new Types.ObjectId(String(expert.sub)),
|
||||||
|
actorName: `${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
||||||
|
actorType: "field_expert",
|
||||||
|
},
|
||||||
|
metadata: { accidentWay: fields.accidentWay },
|
||||||
|
} as any);
|
||||||
|
}
|
||||||
|
|
||||||
await (req as any).save();
|
await (req as any).save();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user