1
0
forked from Yara724/api
This commit is contained in:
SepehrYahyaee
2026-05-10 14:04:11 +03:30
parent 82bb232d28
commit 3fb90cf1c9

View File

@@ -239,13 +239,15 @@ export class ExpertClaimService {
} }
/** /**
* Build a deep-cloned `evaluation` payload with resolved `signLink`s for the * Build a deep-cloned `evaluation` payload with resolved file URLs the
* fields that carry a user signature: * front-end can render directly:
* *
* - `damageExpertReply.userComment.signLink` * - `damageExpertReply.userComment.signLink`
* - `damageExpertReplyFinal.userComment.signLink` * - `damageExpertReplyFinal.userComment.signLink`
* - `ownerInsurerApproval.signLink` * - `ownerInsurerApproval.signLink`
* - `ownerPricedPartsApproval.signLink` * - `ownerPricedPartsApproval.signLink`
* - `damageExpertReply.parts[i].factorLink` (ObjectId → URL)
* - `damageExpertReplyFinal.parts[i].factorLink` (ObjectId → URL)
* *
* Returns `undefined` when there's no evaluation to enrich. * Returns `undefined` when there's no evaluation to enrich.
*/ */
@@ -255,16 +257,21 @@ export class ExpertClaimService {
if (!evaluation || typeof evaluation !== "object") return undefined; if (!evaluation || typeof evaluation !== "object") return undefined;
const ev = JSON.parse(JSON.stringify(evaluation)) as Record<string, unknown>; const ev = JSON.parse(JSON.stringify(evaluation)) as Record<string, unknown>;
const enrichReplyUserComment = async (key: string) => { const enrichReply = async (key: string) => {
const reply = ev[key] as Record<string, unknown> | undefined; const reply = ev[key] as Record<string, unknown> | undefined;
const uc = reply?.userComment as Record<string, unknown> | undefined; if (!reply) return;
const uc = reply.userComment as Record<string, unknown> | undefined;
if (uc?.signDetailId != null) { if (uc?.signDetailId != null) {
const signLink = await this.claimSignLinkFromId(uc.signDetailId); const signLink = await this.claimSignLinkFromId(uc.signDetailId);
(reply as Record<string, unknown>).userComment = { ...uc, signLink }; reply.userComment = { ...uc, signLink };
} }
// Resolve each `parts[].factorLink` ObjectId to a downloadable URL.
// `populateFactorLinks` mutates in place — safe here because `ev` was
// deep-cloned via JSON above, so we never touch the live mongoose doc.
await this.populateFactorLinks(reply);
}; };
await enrichReplyUserComment("damageExpertReply"); await enrichReply("damageExpertReply");
await enrichReplyUserComment("damageExpertReplyFinal"); await enrichReply("damageExpertReplyFinal");
const enrichApproval = async (key: string) => { const enrichApproval = async (key: string) => {
const o = ev[key] as Record<string, unknown> | undefined; const o = ev[key] as Record<string, unknown> | undefined;