forked from Yara724/api
Fixed lock
This commit is contained in:
@@ -25,9 +25,8 @@ export function resolvePersistentReviewAssigneeId(
|
||||
if (fromField != null && String(fromField).length > 0) {
|
||||
return String(fromField);
|
||||
}
|
||||
const fromHistory = history?.find(
|
||||
(h) => h.type === assignedHistoryType,
|
||||
)?.actor?.actorId;
|
||||
const fromHistory = history?.find((h) => h.type === assignedHistoryType)
|
||||
?.actor?.actorId;
|
||||
if (fromHistory != null && String(fromHistory).length > 0) {
|
||||
return String(fromHistory);
|
||||
}
|
||||
@@ -43,8 +42,7 @@ export function buildExpertAssignConflictForOtherReviewer(
|
||||
message: string;
|
||||
lockedBy: { actorId: string; actorName?: string; lockedAt?: string };
|
||||
} {
|
||||
const assignee =
|
||||
workflow?.assignedForReviewBy ?? workflow?.lockedBy;
|
||||
const assignee = workflow?.assignedForReviewBy ?? workflow?.lockedBy;
|
||||
const lockedAt = workflow?.lockedAt;
|
||||
return {
|
||||
success: false,
|
||||
@@ -53,25 +51,28 @@ export function buildExpertAssignConflictForOtherReviewer(
|
||||
lockedBy: {
|
||||
actorId: assigneeId,
|
||||
actorName: assignee?.actorName,
|
||||
lockedAt: lockedAt
|
||||
? new Date(lockedAt as Date).toISOString()
|
||||
: undefined,
|
||||
lockedAt: lockedAt ? new Date(lockedAt as Date).toISOString() : undefined,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/** Copy lock holder into `assignedForReviewBy` when persisting a TTL unlock. */
|
||||
export function blameWorkflowAssigneeToPersistOnLockExpiry(
|
||||
workflow: WorkflowAssigneeRef | undefined,
|
||||
): WorkflowAssigneeRef["assignedForReviewBy"] | undefined {
|
||||
if (workflow?.assignedForReviewBy) {
|
||||
return undefined;
|
||||
}
|
||||
return workflow?.lockedBy;
|
||||
workflow: any,
|
||||
request: any,
|
||||
) {
|
||||
const hasDecision = !!request?.expert?.decision;
|
||||
return hasDecision ? (workflow?.assignedForReviewBy ?? null) : null;
|
||||
}
|
||||
|
||||
export function claimWorkflowAssigneeToPersistOnLockExpiry(
|
||||
workflow: WorkflowAssigneeRef | undefined,
|
||||
): WorkflowAssigneeRef["assignedForReviewBy"] | undefined {
|
||||
return blameWorkflowAssigneeToPersistOnLockExpiry(workflow);
|
||||
workflow: any,
|
||||
claim: any,
|
||||
): typeof workflow.assignedForReviewBy | null {
|
||||
// If a decision or resend was already submitted, preserve ownership
|
||||
const hasDecision =
|
||||
!!claim?.evaluation?.damageExpertReply ||
|
||||
!!claim?.evaluation?.damageExpertReplyFinal ||
|
||||
!!claim?.evaluation?.damageExpertResend;
|
||||
|
||||
return hasDecision ? (workflow?.assignedForReviewBy ?? null) : null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user