forked from Yara724/api
Compare commits
5 Commits
f277d87dfa
...
9084f8fafb
| Author | SHA1 | Date | |
|---|---|---|---|
| 9084f8fafb | |||
| b216a363fb | |||
|
|
b2391751f0 | ||
| df6d2bd04d | |||
| 672ec25438 |
@@ -3854,24 +3854,40 @@ export class RequestManagementService {
|
||||
}
|
||||
|
||||
async getAllBlameRequestsV2(user: any): Promise<any> {
|
||||
console.log(user)
|
||||
try {
|
||||
const requests = await this.blameRequestDbService.find({
|
||||
parties: {
|
||||
$elemMatch: {
|
||||
'person.userId': new Types.ObjectId(user.sub)
|
||||
const requests = await this.blameRequestDbService.find(
|
||||
{
|
||||
"parties.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) {
|
||||
this.logger.error("Error: ", err);
|
||||
throw new InternalServerErrorException(
|
||||
"Something Went Wrong",
|
||||
);
|
||||
throw new InternalServerErrorException("Something Went Wrong");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
||||
Reference in New Issue
Block a user