forked from Yara724/api
Added expert field mirror flow
This commit is contained in:
@@ -87,6 +87,32 @@ export function assertClaimCaseForTenant(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true when a field expert (no clientKey) initiated this claim via an
|
||||
* expert-initiated IN_PERSON blame file.
|
||||
*/
|
||||
export function claimCaseInitiatedByFieldExpert(
|
||||
doc: any,
|
||||
actor: { sub: string },
|
||||
): boolean {
|
||||
return (
|
||||
!!doc.initiatedByFieldExpertId &&
|
||||
String(doc.initiatedByFieldExpertId) === String(actor.sub)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Authorization check that works for both damage experts (clientKey tenant
|
||||
* scope) and field experts (initiatedByFieldExpertId ownership).
|
||||
*/
|
||||
export function assertClaimCaseForExpertActor(
|
||||
doc: any,
|
||||
actor: { sub: string; clientKey?: string },
|
||||
): void {
|
||||
if (claimCaseInitiatedByFieldExpert(doc, actor)) return;
|
||||
assertClaimCaseForTenant(doc, actor);
|
||||
}
|
||||
|
||||
export function resolveGuiltyPartyClientId(doc: any): string | null {
|
||||
const parties: any[] = doc?.parties ?? [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user