1
0
forked from Yara724/api

Compare commits

..

5 Commits

View File

@@ -3854,24 +3854,40 @@ export class RequestManagementService {
} }
async getAllBlameRequestsV2(user: any): Promise<any> { async getAllBlameRequestsV2(user: any): Promise<any> {
console.log(user)
try { try {
const requests = await this.blameRequestDbService.find({ const requests = await this.blameRequestDbService.find(
parties: { {
$elemMatch: { "parties.person.userId": new Types.ObjectId(user.sub),
'person.userId': new Types.ObjectId(user.sub) },
} {
select: "requestNo type status blameStatus createdAt updatedAt parties",
} }
}, { select: "requestNo type status blameStatus createdAt updatedAt" }); );
return requests;
const enriched = requests.map((req: any) => {
const party = req.parties.find(
(p: any) => String(p.person.userId) === String(user.sub)
);
const obj = req.toObject();
delete obj.parties; // remove parties completely
return {
...obj,
userSide: party?.role ?? null,
};
});
return enriched;
} catch (err) { } catch (err) {
this.logger.error("Error: ", err); this.logger.error("Error: ", err);
throw new InternalServerErrorException( throw new InternalServerErrorException("Something Went Wrong");
"Something Went Wrong",
);
} }
} }
/** /**
* V2: Get one blame request by id. Access allowed if current user is a party (by userId or phone) * V2: Get one blame request by id. Access allowed if current user is a party (by userId or phone)
* or the initiating field expert. For expert-initiated LINK, party access by phone is sufficient. * or the initiating field expert. For expert-initiated LINK, party access by phone is sufficient.