FIXED FILE REVIEWER GET ALL

This commit is contained in:
SepehrYahyaee
2026-07-01 16:54:24 +03:30
parent 0c5a2fe38b
commit 6be9ff16e1
5 changed files with 213 additions and 12 deletions

View File

@@ -4129,6 +4129,28 @@ export class RequestManagementService {
* Verify the current user (field expert) can access this BlameRequest (v2).
*/
private verifyExpertAccessForBlameV2(req: any, expert: any): void {
// FILE_REVIEWER can access any sealed expert-initiated IN_PERSON file
// (status WAITING_FOR_FILE_REVIEWER or beyond) scoped to their clientKey.
if (expert?.role === RoleEnum.FILE_REVIEWER) {
if (
!req?.expertInitiated ||
req?.creationMethod !== CreationMethod.IN_PERSON
) {
throw new ForbiddenException(
"FileReviewer can only access expert-initiated IN_PERSON files.",
);
}
if (
req.status !== CaseStatus.WAITING_FOR_FILE_REVIEWER &&
req.status !== CaseStatus.WAITING_FOR_EXPERT &&
req.status !== CaseStatus.COMPLETED
) {
throw new ForbiddenException(
"This file has not been sealed by a FileMaker yet.",
);
}
return;
}
if (req?.expertInitiated && req?.initiatedByFieldExpertId) {
if (String(req.initiatedByFieldExpertId) !== String(expert?.sub)) {
throw new ForbiddenException(
@@ -8815,6 +8837,7 @@ export class RequestManagementService {
const fresh = await this.blameRequestDbService.findById(requestId);
if (fresh) {
const isFileMakerActor = expert?.role === RoleEnum.FILE_MAKER;
if (partyRole === PartyRole.FIRST) {
this.pushWorkflowSteps(fresh, [
WorkflowStep.FIRST_LOCATION,
@@ -8823,14 +8846,17 @@ export class RequestManagementService {
WorkflowStep.FIRST_SIGN,
WorkflowStep.FIRST_COMPLETED,
]);
fresh.workflow.currentStep =
fresh.type === BlameRequestType.THIRD_PARTY
? WorkflowStep.FIRST_INVITE_SECOND
: WorkflowStep.FIRST_COMPLETED;
fresh.workflow.nextStep =
fresh.type === BlameRequestType.THIRD_PARTY
? WorkflowStep.SECOND_INITIAL_FORM
: WorkflowStep.WAITING_FOR_GUILT_DECISION;
if (fresh.type === BlameRequestType.THIRD_PARTY) {
fresh.workflow.currentStep = WorkflowStep.FIRST_INVITE_SECOND;
fresh.workflow.nextStep = WorkflowStep.SECOND_INITIAL_FORM;
} else {
// CAR_BODY: FileMaker is done — seal the file for FileReviewer pickup
fresh.workflow.currentStep = WorkflowStep.FIRST_COMPLETED;
fresh.workflow.nextStep = WorkflowStep.WAITING_FOR_GUILT_DECISION;
if (isFileMakerActor) {
fresh.status = CaseStatus.WAITING_FOR_FILE_REVIEWER;
}
}
} else {
this.pushWorkflowSteps(fresh, [
WorkflowStep.SECOND_LOCATION,
@@ -8841,6 +8867,10 @@ export class RequestManagementService {
]);
fresh.workflow.currentStep = WorkflowStep.SECOND_COMPLETED;
fresh.workflow.nextStep = WorkflowStep.WAITING_FOR_GUILT_DECISION;
// THIRD_PARTY: second party sign is FileMaker's last step — seal for FileReviewer
if (isFileMakerActor) {
fresh.status = CaseStatus.WAITING_FOR_FILE_REVIEWER;
}
}
await (fresh as any).save();
}