locations dynamically in fanavaran

This commit is contained in:
2026-09-02 15:31:55 +03:30
parent ebfeef9e01
commit 5c2b660600
10 changed files with 307 additions and 4 deletions

View File

@@ -48,6 +48,7 @@ import { ReqBlameStatus } from "src/Types&Enums/blame-request-management/status.
import { StepsEnum } from "src/Types&Enums/blame-request-management/steps.enum";
import { ExpertDbService } from "src/users/entities/db-service/expert.db.service";
import { UserDbService } from "src/users/entities/db-service/user.db.service";
import { FanavaranLocationService } from "src/fanavaran/fanavaran-location.service";
import { isOtpExpiryActive } from "src/helpers/user-otp-expiry";
import { parseIranLocalDateTime } from "src/helpers/iran-datetime";
import { applyListQueryV2 } from "src/helpers/list-query-v2";
@@ -617,6 +618,7 @@ export class RequestManagementService {
private readonly workflowStepDbService: WorkflowStepDbService,
private readonly hashService: HashService,
private readonly userAuthService: UserAuthService,
private readonly fanavaranLocationService: FanavaranLocationService,
) {}
/**
@@ -4707,6 +4709,12 @@ export class RequestManagementService {
if (!assignedId) {
// Atomically claim — ignore if another reviewer won the race (they would have
// been caught by the assignedId check above on their own first call).
await this.fanavaranLocationService.assertMakerReviewerLocationCompatible({
fileMakerId: req?.initiatedByFieldExpertId
? String(req.initiatedByFieldExpertId)
: null,
fileReviewerId: String(expert.sub),
});
await this.blameRequestDbService.findOneAndUpdate(
{
_id: req._id,
@@ -4718,6 +4726,14 @@ export class RequestManagementService {
{ $set: { assignedFileReviewerId: new Types.ObjectId(String(expert.sub)) } },
{ new: false },
);
} else {
// Already assigned to this reviewer — re-check location compatibility.
await this.fanavaranLocationService.assertMakerReviewerLocationCompatible({
fileMakerId: req?.initiatedByFieldExpertId
? String(req.initiatedByFieldExpertId)
: null,
fileReviewerId: String(expert.sub),
});
}
return;
}