fix(workflows): resolve QA blockers and protect case evidence

Fix registrar signing, reviewer re-entry, replacement evidence freshness, owner decision and rating races, multipart objections, vehicle serialization and product reporting.

Validate uploaded media with FFmpeg, serve evidence through expiring signed links, and add targeted regressions plus a dry-run repair for prematurely completed visit cases.
This commit is contained in:
SepehrYahyaee
2026-11-22 12:50:22 +03:30
parent abc40df199
commit 6b968c0952
37 changed files with 1118 additions and 211 deletions
@@ -1,3 +1,4 @@
import { WeatherCondition, RoadCondition, LightCondition } from "src/Types&Enums/blame-request-management/accident-conditions.enum";
import { UserClaimBranchService, userClaimBranchContext, usesUserClaimBranch } from "src/client/user-claim-branch.service";
import { normalizeAccidentLocation } from "./accident-location";
import {
@@ -215,6 +216,13 @@ export class RequestManagementService {
}
/** Keep eligibility rejections distinct from an unavailable CAR_BODY provider. */
private assertAccidentConditions(body: {weatherCondition?: unknown; roadCondition?: unknown; lightCondition?: unknown}): void {
for (const [value, choices] of [[body.weatherCondition, WeatherCondition], [body.roadCondition, RoadCondition], [body.lightCondition, LightCondition]] as const) {
if (value != null && !Object.values(choices).includes(value as never))
throw new BadRequestException("شرایط آب‌وهوا، راه یا روشنایی حادثه معتبر نیست. گزینه‌های فرم را دوباره انتخاب کنید.");
}
}
private assertCarBodyDescriptionMinimum(
requestType: BlameRequestType | string | undefined,
description: unknown,
@@ -2910,6 +2918,7 @@ export class RequestManagementService {
);
this.assertCarBodyDescriptionMinimum(req.type, body.desc);
this.assertAccidentConditions(body as DescriptionDto);
// Set userId for party if not already set (important for second party)
if (!party.person) party.person = {} as any;
@@ -5075,6 +5084,7 @@ export class RequestManagementService {
formData?.expertDescription?.desc,
);
this.assertAccidentConditions(formData?.expertDescription ?? {});
const firstPartyUserId = await this.getOrCreateUserByPhoneNumber(
formData.firstPartyPhoneNumber,
);
@@ -5399,6 +5409,7 @@ export class RequestManagementService {
throw new BadRequestException("expertDescription.desc is required.");
}
this.assertAccidentConditions(formData?.expertDescription ?? {});
const firstPartyUserId = await this.getOrCreateUserByPhoneNumber(
formData.firstPartyPhoneNumber,
);
@@ -5846,7 +5857,7 @@ export class RequestManagementService {
const req = await this.blameRequestDbService.findById(requestId);
if (!req) throw new NotFoundException("Request not found");
if (
!req.expertInitiated ||
(!req.expertInitiated && !req.registrarInitiated) ||
req.creationMethod !== CreationMethod.IN_PERSON
) {
throw new BadRequestException(
@@ -5889,7 +5900,7 @@ export class RequestManagementService {
const signatureData = {
fileId: String((signDoc as any)._id),
fileName: signFile.filename,
fileUrl: signFile.path,
fileUrl: buildFileLink(signFile.path),
};
const updatePayload: any = {
$set: {
@@ -6578,7 +6589,7 @@ export class RequestManagementService {
const signatureData = {
fileId: String((signDoc as any)._id),
fileName: signFile.filename,
fileUrl: signFile.path,
fileUrl: buildFileLink(signFile.path),
};
const confirmationPayload = {
@@ -8203,7 +8214,7 @@ export class RequestManagementService {
const signatureData = {
fileId: String((signDoc as any)._id),
fileName: signFile.filename,
fileUrl: signFile.path,
fileUrl: buildFileLink(signFile.path),
};
await this.blameRequestDbService.findByIdAndUpdate(requestId, {
@@ -8700,6 +8711,7 @@ export class RequestManagementService {
const role = this.resolvePartyRoleV3(req, partyRole);
this.assertBlameV3PartyDetailPhase(req, role);
this.assertCarBodyDescriptionMinimum(req.type, body.desc);
this.assertAccidentConditions(body as DescriptionDto);
// accidentDate and accidentTime are only required for the first (guilty)
// party — the second (damaged) party can skip them.
@@ -8724,8 +8736,6 @@ export class RequestManagementService {
const idx = this.getPartyIndex(req, role);
if (idx === -1) throw new BadRequestException(`${role} party not found`);
this.assertCarBodyDescriptionMinimum(req.type, body.desc);
const party = req.parties[idx];
if (req.type === BlameRequestType.CAR_BODY && role === PartyRole.FIRST) {
await this.validateCarBodyAccidentCoverage(party, body.accidentDate);