Skip to content

Commit

Permalink
fix(core): early return empty fields, fix #459
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 28, 2022
1 parent ae44c54 commit 131b8d3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/core/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export class Session<U extends User.Field = never, G extends Channel.Field = nev
}

async getChannel<K extends Channel.Field = never>(id = this.channelId, fields: K[] = []) {
if (!fields.length) return { platform: this.platform, id }
const channel = await this.app.database.getChannel(this.platform, id, fields)
if (channel) return channel
const assignee = await this.resolveValue(this.app.options.autoAssign) ? this.selfId : ''
Expand Down Expand Up @@ -233,6 +234,7 @@ export class Session<U extends User.Field = never, G extends Channel.Field = nev
}

async getUser<K extends User.Field = never>(id = this.userId, fields: K[] = []) {
if (!fields.length) return { [this.platform]: id }
const user = await this.app.database.getUser(this.platform, id, fields)
if (user) return user
const authority = await this.resolveValue(this.app.options.autoAuthorize)
Expand Down

0 comments on commit 131b8d3

Please sign in to comment.