forked from Yara724/api
YARA-725
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user