🩹 The API was missing some ease of use parameters

Signed-off-by: Pau Costa <mico@micodev.es>
pull/2/head
Pau Costa Ferrer 2024-02-09 13:45:20 +01:00
parent e27423a2e5
commit 0cdcc915f4
2 changed files with 3 additions and 3 deletions

View File

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

View File

@ -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())
}