Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/entities/organisation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class Organisation {
@Property()
name!: string

@OneToMany(() => Game, (game) => game.organisation, { eager: true })
@OneToMany(() => Game, (game) => game.organisation)
games = new Collection<Game>(this)

@OneToOne({ orphanRemoval: true, eager: true })
Expand Down
4 changes: 2 additions & 2 deletions src/policies/policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export default class Policy extends ServicePolicy {
}

async canAccessGame(gameId: number): Promise<boolean> {
const game = await this.em.getRepository(Game).findOne(gameId, {
const game = await this.em.repo(Game).findOne(gameId, {
...getResultCacheOptions(`can-access-game-${gameId}`),
populate: ['organisation']
populate: ['organisation.id']
})

if (!game) this.ctx.throw(404, 'Game not found')
Expand Down
3 changes: 3 additions & 0 deletions src/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ export default class UserService extends Service {
path: '/me'
})
async me(req: Request): Promise<Response> {
const em: EntityManager = req.ctx.em
const user = await getUserFromToken(req.ctx)
// cache doesn't include the full organisation
await em.populate(user, ['organisation.games'])

return {
status: 200,
Expand Down
4 changes: 2 additions & 2 deletions tests/services/_api/game-channel-api/members.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ describe('Game channel API service - members', () => {
it('should filter by player groups', async () => {
const [apiKey, token] = await createAPIKeyAndToken([APIKeyScope.READ_GAME_CHANNELS])

const rule = new PlayerGroupRule(PlayerGroupRuleName.GTE, 'props.currentLevel')
const rule = new PlayerGroupRule(PlayerGroupRuleName.GTE, 'props.someRandomProp')
rule.castType = PlayerGroupRuleCastType.DOUBLE
rule.operands = ['60']

Expand All @@ -324,7 +324,7 @@ describe('Game channel API service - members', () => {

const player = await new PlayerFactory([apiKey.game]).state((player) => ({
props: new Collection<PlayerProp>(player, [
new PlayerProp(player, 'currentLevel', '60')
new PlayerProp(player, 'someRandomProp', '60')
])
})).one()
const otherPlayer = await new PlayerFactory([apiKey.game]).one()
Expand Down