1
0
forked from Yara724/api

YARA-1073

This commit is contained in:
SepehrYahyaee
2026-06-28 15:53:34 +03:30
parent f7f7f4548d
commit 4552450fbc
2 changed files with 21 additions and 2 deletions

View File

@@ -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 };
}
}

View File

@@ -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,