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

Reviewed-on: Yara724/api#63
This commit is contained in:
2026-05-10 14:16:05 +03:30
3 changed files with 20 additions and 11 deletions

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;

View File

@@ -1429,6 +1429,7 @@ export class RequestManagementService {
); );
await this.smsOrchestrationService.sendInviteLink( await this.smsOrchestrationService.sendInviteLink(
secondPartyPhone, secondPartyPhone,
req.publicId,
url, url,
); );
return { return {
@@ -1477,7 +1478,7 @@ export class RequestManagementService {
frontendRoute, frontendRoute,
requestId, requestId,
); );
await this.smsOrchestrationService.sendInviteLink(phoneNumber, url); await this.smsOrchestrationService.sendInviteLink(phoneNumber, req.publicId, url);
return { return {
requestId: req._id, requestId: req._id,
@@ -2399,7 +2400,7 @@ export class RequestManagementService {
frontendRoutes, frontendRoutes,
requestId, requestId,
); );
await this.smsOrchestrationService.sendInviteLink(phoneNumber, URL); await this.smsOrchestrationService.sendInviteLink(phoneNumber, request.publicId, URL);
return { url: URL }; return { url: URL };
} }

View File

@@ -50,11 +50,12 @@ export class SmsOrchestrationService implements OnModuleInit {
return `${process.env.URL}/caseClaim?token=${claimRequestId}`; return `${process.env.URL}/caseClaim?token=${claimRequestId}`;
} }
async sendInviteLink(phoneNumber: string, link: string): Promise<boolean> { async sendInviteLink(phoneNumber: string, publicId: string, link: string): Promise<boolean> {
return this.sendTemplate({ return this.sendTemplate({
template: "yara724-invite-link", template: "yara724-invite-link",
receptor: phoneNumber, receptor: phoneNumber,
token: link, token: publicId,
token2: link,
}); });
} }