🩹 The API was missing some ease of use parameters
Signed-off-by: Pau Costa <mico@micodev.es>pull/2/head
parent
e27423a2e5
commit
0cdcc915f4
|
|
@ -38,7 +38,7 @@ export class PostController {
|
|||
*/
|
||||
public getAllPosts = catchAsync(async (_req, res, _next) => {
|
||||
const posts = await this.postRepository.find({
|
||||
relations: { createdBy: true },
|
||||
relations: { createdBy: true, likedBy: true, comments: {createdBy: true} },
|
||||
});
|
||||
|
||||
// Remove sensitive fields
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@ export class Post {
|
|||
|
||||
public deleteSensitiveFields(){
|
||||
this.createdBy.deleteSensitiveFields()
|
||||
if(this.likedBy){
|
||||
if(this.likedBy.length > 0){
|
||||
this.likedBy.forEach(user => user.deleteSensitiveFields())
|
||||
}
|
||||
if(this.comments){
|
||||
if(this.comments.length > 0){
|
||||
this.comments.forEach(comment => comment.createdBy.deleteSensitiveFields())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue