Skip to content

Commit

Permalink
Merge branch 'main' into Embed-youtube
Browse files Browse the repository at this point in the history
  • Loading branch information
wirapratamaz authored Oct 24, 2024
2 parents d404815 + fa6432c commit 8e4578a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 0 additions & 1 deletion .maintain/deployment/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ services:
default:

db_migration:
<<: *api
container_name: db_migration
restart: none
entrypoint: node ./dist/migrate
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/helpers/database.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ export async function givenRepositories(testdb: any) {
timelineConfigRepository,
userRepository,
userExperienceRepository,
transactionRepository,
friendService,
postService,
currentUser,
Expand Down
24 changes: 24 additions & 0 deletions 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 @@ -183,6 +187,26 @@ export class ExperienceService {
userId: {eq: this.currentUser[securityId]},
},
);
const experience = await this.experienceRepository.findById(id);

if (
experience?.exclusive === true &&
this.currentUser[securityId] !== experience.createdBy
) {
const transaction = await this.transactionRepository.find({
where: {
type: ReferenceType.UNLOCKABLETIMELINE,
from: this.currentUser[securityId],
to: experience.createdBy,
referenceId: experience.id,
},
});
if (transaction.length === 0) {
return [];
} else {
return this.postService.find(filter, id, true);
}
}

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

0 comments on commit 8e4578a

Please sign in to comment.