forked from Yara724/api
YARA-1073
This commit is contained in:
@@ -23,7 +23,9 @@ export class BlameRequestDbService {
|
||||
return this.blameRequestModel.findOne(filter);
|
||||
}
|
||||
|
||||
async findById(id: string | Types.ObjectId): Promise<BlameRequestDocument | null> {
|
||||
async findById(
|
||||
id: string | Types.ObjectId,
|
||||
): Promise<BlameRequestDocument | null> {
|
||||
return this.blameRequestModel.findById(id);
|
||||
}
|
||||
|
||||
@@ -72,5 +74,11 @@ export class BlameRequestDbService {
|
||||
: this.blameRequestModel.find(filter);
|
||||
return query.exec() as Promise<BlameRequestDocument[]>;
|
||||
}
|
||||
}
|
||||
|
||||
async deleteMany(
|
||||
filter: FilterQuery<BlameRequest>,
|
||||
): Promise<{ deletedCount: number }> {
|
||||
const result = await this.blameRequestModel.deleteMany(filter);
|
||||
return { deletedCount: result.deletedCount };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4367,6 +4367,17 @@ export class RequestManagementService {
|
||||
// For IN_PERSON files the phone + userId are stored when verify-party-otp is called.
|
||||
const parties: any[] = [{ role: PartyRole.FIRST, person: {} }];
|
||||
|
||||
// Before creating, clean up any orphaned IN_PERSON shell from this expert
|
||||
// that never had its first party OTP verified.
|
||||
if (dto.creationMethod === CreationMethod.IN_PERSON) {
|
||||
await this.blameRequestDbService.deleteMany({
|
||||
initiatedByFieldExpertId: expertId,
|
||||
creationMethod: CreationMethod.IN_PERSON,
|
||||
"workflow.currentStep": firstStep.stepKey, // still at CREATED
|
||||
"parties.0.person.userId": { $exists: false }, // no verified party yet
|
||||
});
|
||||
}
|
||||
|
||||
const created = await this.blameRequestDbService.create({
|
||||
publicId,
|
||||
requestNo: publicId,
|
||||
|
||||
Reference in New Issue
Block a user