Skip to content

Commit

Permalink
Update post.service.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
RiXelanya committed Nov 15, 2023
1 parent 1bdfd18 commit c0ce862
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/services/post.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
DraftPost,
Experience,
ExperiencePost,
ExperienceRelations,
ExtendedPost,
Friend,
People,
Expand All @@ -37,6 +38,7 @@ import {
CommentRepository,
DraftPostRepository,
ExperiencePostRepository,
ExperienceEditorRepository,
ExperienceRepository,
FriendRepository,
PeopleRepository,
Expand Down Expand Up @@ -68,6 +70,8 @@ export class PostService {
private experienceRepository: ExperienceRepository,
@repository(ExperiencePostRepository)
private experiencePostRepository: ExperiencePostRepository,
@repository(ExperienceEditorRepository)
private experienceEditorRepository: ExperienceEditorRepository,
@repository(FriendRepository)
private friendRepository: FriendRepository,
@repository(PeopleRepository)
Expand Down Expand Up @@ -743,12 +747,28 @@ export class PostService {
}

private async getVisibility(userId: string, timelineIds = [] as string[]) {
const timelines = await this.experienceRepository.find({
const timeline = this.experienceRepository.find({
where: {
id: {inq: timelineIds},
createdBy: userId,
},
});
const editable = this.experienceEditorRepository.find({
where: {
experienceId: {inq: timelineIds},
userId,
},
}).then(res => {
const query = res.map(res => res.userId)
return this.experienceRepository.find({
where: {
id: {inq: query},
},
});
});
const timelines = await Promise.all([timeline,editable]).then(res => {
return [...res[0],...res[1]]
})

if (timelines.length <= 0) {
throw new HttpErrors.UnprocessableEntity('TimelineNotFound');
Expand Down

0 comments on commit c0ce862

Please sign in to comment.