Skip to content

Commit

Permalink
fix: visibility timeline (#777)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenkristian committed Feb 17, 2023
1 parent 0b388f4 commit 2738fd2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/services/post.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class PostService {
await this.experienceRepository.findById(timelineId);
selectedUsers = [...selectedUsers, ...experience.selectedUserIds];
}
rawPost.selectedUserIds = selectedUsers;
rawPost.selectedUserIds = [...new Set(selectedUsers)];
} else if (rawPost.visibility !== VisibilityType.SELECTED) {
rawPost.selectedUserIds = [];
}
Expand Down Expand Up @@ -586,6 +586,15 @@ export class PostService {
return;
}

case VisibilityType.TIMELINE: {
const {selectedUserIds} = post;
const isSelected = selectedUserIds.find(e => e === currentUserId);
if (!isSelected) {
throw new HttpErrors.Forbidden('OnlySelectedUser');
}
return;
}

default:
throw new HttpErrors.Forbidden('RestrictedPost');
}
Expand Down

0 comments on commit 2738fd2

Please sign in to comment.