forked from Yara724/api
YARA-985
This commit is contained in:
@@ -135,6 +135,26 @@ export class RequestManagementService {
|
||||
throw new BadRequestException(`Step ${stepKey} is not a party-scoped step`);
|
||||
}
|
||||
|
||||
private resolveBlameHistoryActorType(actor: any): string {
|
||||
switch (actor?.role) {
|
||||
case RoleEnum.FILE_MAKER:
|
||||
return "file_maker";
|
||||
case RoleEnum.FILE_REVIEWER:
|
||||
return "file_reviewer";
|
||||
case RoleEnum.REGISTRAR:
|
||||
return "registrar";
|
||||
case RoleEnum.CALL_CENTER:
|
||||
return "call_center";
|
||||
case RoleEnum.DAMAGE_EXPERT:
|
||||
return "damage_expert";
|
||||
case RoleEnum.EXPERT:
|
||||
return "expert";
|
||||
case RoleEnum.FIELD_EXPERT:
|
||||
default:
|
||||
return "field_expert";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse map: Fanavaran/Tejarat numeric letter code → Persian plate letter.
|
||||
* Tejarat inquiry stores Plk2 as a numeric code (e.g. 12 → "م", 5 → "د").
|
||||
@@ -4992,7 +5012,7 @@ export class RequestManagementService {
|
||||
actor: {
|
||||
actorId: expertId,
|
||||
actorName: `${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(expert),
|
||||
},
|
||||
metadata: { creationMethod: dto.creationMethod, type: dto.type },
|
||||
});
|
||||
@@ -5093,7 +5113,7 @@ export class RequestManagementService {
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(expert.sub),
|
||||
actorName: `${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(expert),
|
||||
},
|
||||
metadata: { sentTo, template: "yara-field-expert-link" },
|
||||
});
|
||||
@@ -5279,8 +5299,7 @@ export class RequestManagementService {
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(expert.sub),
|
||||
actorName: `${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
||||
actorType:
|
||||
expert?.role === RoleEnum.REGISTRAR ? "registrar" : "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(expert),
|
||||
},
|
||||
metadata: {
|
||||
firstPartyVerified: true,
|
||||
@@ -5375,7 +5394,7 @@ export class RequestManagementService {
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(actor.sub),
|
||||
actorName: `${actor.firstName || ""} ${actor.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(actor),
|
||||
},
|
||||
metadata: { phoneNumber: phone },
|
||||
} as any);
|
||||
@@ -5516,7 +5535,7 @@ export class RequestManagementService {
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(actor.sub),
|
||||
actorName: `${actor.firstName || ""} ${actor.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(actor),
|
||||
},
|
||||
metadata: { partyRole: role, phoneNumber: phone },
|
||||
} as any);
|
||||
@@ -5558,8 +5577,7 @@ export class RequestManagementService {
|
||||
actorId: new Types.ObjectId(actor.sub),
|
||||
actorName:
|
||||
`${actor.firstName || ""} ${actor.lastName || ""}`.trim(),
|
||||
actorType:
|
||||
actor?.role === RoleEnum.REGISTRAR ? "registrar" : "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(actor),
|
||||
},
|
||||
metadata: { advancedTo: WorkflowStep.CAR_BODY_ACCIDENT_TYPE },
|
||||
} as any);
|
||||
@@ -5593,10 +5611,8 @@ export class RequestManagementService {
|
||||
type: "AUTO_CONFESSION_SKIPPED",
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(actor.sub),
|
||||
actorName:
|
||||
`${actor.firstName || ""} ${actor.lastName || ""}`.trim(),
|
||||
actorType:
|
||||
actor?.role === RoleEnum.REGISTRAR ? "registrar" : "field_expert",
|
||||
actorName: `${actor.firstName || ""} ${actor.lastName || ""}`.trim(),
|
||||
actorType: this.resolveBlameHistoryActorType(actor),
|
||||
},
|
||||
metadata: {
|
||||
reason:
|
||||
@@ -5621,9 +5637,9 @@ export class RequestManagementService {
|
||||
type: "SECOND_PARTY_OTP_VERIFIED_ADVANCED",
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(actor.sub),
|
||||
actorName: `${actor.firstName || ""} ${actor.lastName || ""}`.trim(),
|
||||
actorType:
|
||||
actor?.role === RoleEnum.REGISTRAR ? "registrar" : "field_expert",
|
||||
actorName:
|
||||
`${actor.firstName || ""} ${actor.lastName || ""}`.trim(),
|
||||
actorType: this.resolveBlameHistoryActorType(actor),
|
||||
},
|
||||
metadata: {
|
||||
phoneNumber: phone,
|
||||
@@ -6383,7 +6399,7 @@ export class RequestManagementService {
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(expert.sub),
|
||||
actorName: `${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(expert),
|
||||
},
|
||||
metadata: {},
|
||||
} as any);
|
||||
@@ -6589,7 +6605,7 @@ export class RequestManagementService {
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(expert.sub),
|
||||
actorName: `${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(expert),
|
||||
},
|
||||
metadata: { guiltyPartyPhoneNumber: formData.guiltyPartyPhoneNumber },
|
||||
} as any);
|
||||
@@ -6653,8 +6669,7 @@ export class RequestManagementService {
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(expert.sub),
|
||||
actorName: `${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
||||
actorType:
|
||||
expert?.role === RoleEnum.REGISTRAR ? "registrar" : "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(expert),
|
||||
},
|
||||
metadata: {
|
||||
hasLocation: true,
|
||||
@@ -6714,7 +6729,7 @@ export class RequestManagementService {
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(expert.sub),
|
||||
actorName: `${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(expert),
|
||||
},
|
||||
metadata: { videoId: firstParty.evidence.videoId },
|
||||
} as any);
|
||||
@@ -6771,7 +6786,7 @@ export class RequestManagementService {
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(expert.sub),
|
||||
actorName: `${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(expert),
|
||||
},
|
||||
metadata: {},
|
||||
} as any);
|
||||
@@ -7001,7 +7016,7 @@ export class RequestManagementService {
|
||||
actorId: new Types.ObjectId(String(expert.sub)),
|
||||
actorName:
|
||||
`${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(expert),
|
||||
},
|
||||
metadata: {
|
||||
accidentWay: fields.accidentWay,
|
||||
@@ -9065,7 +9080,7 @@ export class RequestManagementService {
|
||||
actorId: new Types.ObjectId(actor.sub),
|
||||
actorName:
|
||||
`${actor.firstName || ""} ${actor.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(actor),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
metadata: {
|
||||
@@ -9904,7 +9919,7 @@ export class RequestManagementService {
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(expert.sub),
|
||||
actorName: `${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(expert),
|
||||
},
|
||||
metadata: { partyRole, accepted: isAccept },
|
||||
} as any);
|
||||
@@ -9971,7 +9986,7 @@ export class RequestManagementService {
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(String(expert.sub)),
|
||||
actorName: `${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(expert),
|
||||
},
|
||||
metadata: { accidentWay: fields.accidentWay },
|
||||
} as any);
|
||||
@@ -10089,11 +10104,11 @@ export class RequestManagementService {
|
||||
|
||||
if (!Array.isArray(req.history)) req.history = [];
|
||||
req.history.push({
|
||||
type: "V3_BLAME_ACCIDENT_VIDEO_UPLOADED",
|
||||
type: "V5_BLAME_ACCIDENT_VIDEO_UPLOADED",
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(expert.sub),
|
||||
actorName: `${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(expert),
|
||||
},
|
||||
metadata: { videoId: videoId ?? null },
|
||||
} as any);
|
||||
@@ -10118,7 +10133,7 @@ export class RequestManagementService {
|
||||
actorId: new Types.ObjectId(expert.sub),
|
||||
actorName:
|
||||
`${expert.firstName || ""} ${expert.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(expert),
|
||||
},
|
||||
timestamp: new Date(),
|
||||
metadata: {
|
||||
@@ -10232,7 +10247,7 @@ export class RequestManagementService {
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(actor.sub),
|
||||
actorName: `${actor.firstName || ""} ${actor.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(actor),
|
||||
},
|
||||
metadata: { partyRole: role, voiceId: String((voiceDoc as any)._id) },
|
||||
} as any);
|
||||
@@ -10275,7 +10290,7 @@ export class RequestManagementService {
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(actor.sub),
|
||||
actorName: `${actor.firstName || ""} ${actor.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(actor),
|
||||
},
|
||||
metadata: { partyRole: role, location: body },
|
||||
} as any);
|
||||
@@ -10309,7 +10324,7 @@ export class RequestManagementService {
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(actor.sub),
|
||||
actorName: `${actor.firstName || ""} ${actor.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(actor),
|
||||
},
|
||||
metadata: { partyRole: role },
|
||||
} as any);
|
||||
@@ -10369,7 +10384,7 @@ export class RequestManagementService {
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(actor.sub),
|
||||
actorName: `${actor.firstName || ""} ${actor.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(actor),
|
||||
},
|
||||
metadata: {
|
||||
partyRole: role,
|
||||
@@ -10425,7 +10440,7 @@ export class RequestManagementService {
|
||||
actor: {
|
||||
actorId: new Types.ObjectId(actor.sub),
|
||||
actorName: `${actor.firstName || ""} ${actor.lastName || ""}`.trim(),
|
||||
actorType: "field_expert",
|
||||
actorType: this.resolveBlameHistoryActorType(actor),
|
||||
},
|
||||
metadata: { car: body.car, object: body.object },
|
||||
} as any);
|
||||
|
||||
Reference in New Issue
Block a user