1
0
forked from Yara724/api
This commit is contained in:
SepehrYahyaee
2026-04-15 12:32:25 +03:30
parent 640b240ada
commit 9a65071276
2 changed files with 36 additions and 3 deletions

View File

@@ -319,8 +319,18 @@ export class ExpertClaimService {
await this.claimRequestManagementDbService.findOne(requestId);
if (!request) throw new BadRequestException("Claim request not found");
if (request.lockFile) {
throw new BadRequestException("Claim request is locked");
const isLocked = !!request.lockFile;
const lockedByCurrent =
String(request?.actorLocked?.actorId || "") === String(actorDetail.sub);
const isLockExpired =
!!request.unlockTime && Date.now() >= new Date(request.unlockTime).getTime();
// Idempotent behavior: same expert can re-enter their locked file.
if (isLocked && lockedByCurrent && !isLockExpired) {
return { _id: requestId, lock: true, message: "Already locked by you" };
}
if (isLocked && !lockedByCurrent && !isLockExpired) {
throw new BadRequestException("Claim request is locked by another expert");
}
if (request.claimStatus === ReqClaimStatus.UserPending) {