forked from Yara724/api
Fix v5 lock and re-submit mechanism
This commit is contained in:
@@ -2671,16 +2671,23 @@ export class ExpertClaimService {
|
||||
if (!reviewerBlame) {
|
||||
throw new NotFoundException("Linked blame file not found.");
|
||||
}
|
||||
const blameStatus = (reviewerBlame as any).status as string;
|
||||
if (blameStatus === "WAITING_FOR_FILE_REVIEWER") {
|
||||
// Phase 1: blame-assign path
|
||||
return this.assignFileReviewerToV4Blame(claimRequestId, claim, actor);
|
||||
}
|
||||
// Phase 2: blame is past the initial assignment step.
|
||||
// Only the reviewer who was assigned during Phase 1 may proceed.
|
||||
const assignedReviewerId = (reviewerBlame as any).assignedFileReviewerId
|
||||
? String((reviewerBlame as any).assignedFileReviewerId)
|
||||
: null;
|
||||
const blameStatus = (reviewerBlame as any).status as string;
|
||||
|
||||
if (blameStatus === "WAITING_FOR_FILE_REVIEWER") {
|
||||
if (assignedReviewerId && assignedReviewerId === actor.sub) {
|
||||
// Reviewer already assigned (e.g. after a FileMaker rejection that reset
|
||||
// blame back to WAITING_FOR_FILE_REVIEWER) — skip Phase 1 and fall
|
||||
// through to the damage-expert workflow lock below.
|
||||
} else {
|
||||
// Phase 1: first-time blame assignment
|
||||
return this.assignFileReviewerToV4Blame(claimRequestId, claim, actor);
|
||||
}
|
||||
} else {
|
||||
// Phase 2: blame is past the initial assignment step.
|
||||
// Only the reviewer who was assigned during Phase 1 may proceed.
|
||||
if (!assignedReviewerId) {
|
||||
throw new BadRequestException({
|
||||
success: false,
|
||||
@@ -2695,8 +2702,8 @@ export class ExpertClaimService {
|
||||
message: "This file is assigned to another reviewer.",
|
||||
});
|
||||
}
|
||||
// Assigned reviewer — fall through to the damage-expert workflow lock below.
|
||||
// (actor.role stays FILE_REVIEWER; assertExpertActorOnClaim checks clientKey scope)
|
||||
}
|
||||
// Fall through to the damage-expert workflow lock below.
|
||||
}
|
||||
|
||||
await this.assertExpertActorOnClaim(claim, actor);
|
||||
@@ -2777,9 +2784,15 @@ export class ExpertClaimService {
|
||||
const now = new Date();
|
||||
const lockSnapshot = await this.snapshotDamageExpert(actor.sub);
|
||||
const expiredAt = new Date(now.getTime() + EXPERT_WORKFLOW_LOCK_TTL_MS);
|
||||
const actorType = isFieldExpertOwner ? "field_expert" : "damage_expert";
|
||||
const actorType = isFieldExpertOwner
|
||||
? "field_expert"
|
||||
: (actor as any).role === RoleEnum.FILE_REVIEWER
|
||||
? "file_reviewer"
|
||||
: "damage_expert";
|
||||
const actorRoleLabel = isFieldExpertOwner
|
||||
? ("field_expert" as const)
|
||||
: (actor as any).role === RoleEnum.FILE_REVIEWER
|
||||
? ("file_reviewer" as const)
|
||||
: ("damage_expert" as const);
|
||||
|
||||
const lockedByPayload = {
|
||||
@@ -2834,7 +2847,13 @@ export class ExpertClaimService {
|
||||
},
|
||||
};
|
||||
|
||||
if (!claim.workflow?.assignedForReviewBy) {
|
||||
// Update assignedForReviewBy whenever a FILE_REVIEWER re-locks after a
|
||||
// FileMaker rejection — the stale payload (from a prior damage-expert cycle)
|
||||
// must be replaced with the actual reviewer so submit checks pass.
|
||||
if (
|
||||
!claim.workflow?.assignedForReviewBy ||
|
||||
(actor as any).role === RoleEnum.FILE_REVIEWER
|
||||
) {
|
||||
baseLockUpdate["workflow.assignedForReviewBy"] = lockedByPayload;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user