Merge pull request 'YARA-1162' (#220) from s.yahyaee/yara724-api:main into main

Reviewed-on: Yara724/api#220
This commit is contained in:
2026-07-27 10:16:22 +03:30

View File

@@ -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 = [];
req.history.push({
type: "V3_ACCIDENT_FIELDS_SAVED",
actor: {
actorId: new Types.ObjectId(String(expert.sub)),
actorName: `${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
actorType: "field_expert",
},
metadata: { accidentWay: fields.accidentWay },
} as any);
// Avoid duplicate history entries on idempotent retries.
const alreadyRecorded = (req.history as any[]).some(
(e: any) => e?.type === "V3_ACCIDENT_FIELDS_SAVED",
);
if (!alreadyRecorded) {
req.history.push({
type: "V3_ACCIDENT_FIELDS_SAVED",
actor: {
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();