Skip to content

Commit

Permalink
fix: update exclusive timeline exclusion logic to fetch transaction (#…
Browse files Browse the repository at this point in the history
…981)

Update experience.service.ts
  • Loading branch information
RiXelanya authored Oct 23, 2024
1 parent 024118d commit 98c713e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/services/experience.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
AccountSettingType,
FriendStatusType,
PlatformType,
ReferenceType,
VisibilityType,
} from '../enums';
import {UserExperienceStatus} from '../enums/user-experience-status.enum';
Expand All @@ -31,6 +32,7 @@ import {
TimelineConfigRepository,
UserRepository,
UserExperienceRepository,
TransactionRepository,
} from '../repositories';
import {FriendService} from './friend.service';
import {PostService} from './post.service';
Expand All @@ -48,6 +50,8 @@ export class ExperienceService {
private userRepository: UserRepository,
@repository(UserExperienceRepository)
private userExperienceRepository: UserExperienceRepository,
@repository(TransactionRepository)
private transactionRepository: TransactionRepository,
@service(FriendService)
private friendService: FriendService,
@service(PostService)
Expand Down Expand Up @@ -189,7 +193,19 @@ export class ExperienceService {
experience?.exclusive === true &&
this.currentUser[securityId] !== experience.createdBy
) {
return [];
const transaction = await this.transactionRepository.findOne({
where: {
type: ReferenceType.UNLOCKABLETIMELINE,
from: this.currentUser[securityId],
to: experience.createdBy,
referenceId: experience.id,
},
});
if (typeof transaction !== null) {
return this.postService.find(filter, id, true);
} else {
return [];
}
}

return this.postService.find(filter, id, true);
Expand Down

0 comments on commit 98c713e

Please sign in to comment.