Skip to content

Commit

Permalink
fix(core): handle anonymous message
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Apr 18, 2020
1 parent 5177f59 commit b0d49f4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/koishi-core/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { Sender } from './sender'
import { Server, createServer, ServerType } from './server'
import { Command, ShortcutConfig, ParsedCommandLine } from './command'
import { Context, Middleware, NextFunction, ContextScope, Events, EventMap } from './context'
import { GroupFlag, UserFlag, UserField, createDatabase, DatabaseConfig, GroupField } from './database'
import { GroupFlag, UserFlag, UserField, createDatabase, DatabaseConfig, GroupField, createUser } from './database'
import { showSuggestions } from './utils'
import { Meta } from './meta'
import { simplify, noop } from 'koishi-utils'
import { simplify, noop, observe } from 'koishi-utils'
import { errors, messages } from './messages'
import { ParsedLine } from './parser'

Expand Down Expand Up @@ -444,7 +444,9 @@ export class App extends Context {
const defaultAuthority = typeof this.options.defaultAuthority === 'function'
? this.options.defaultAuthority(meta)
: this.options.defaultAuthority || 0
const user = await this.database.observeUser(meta.userId, defaultAuthority, Array.from(userFields))
const user = meta.anonymous
? observe(createUser(meta.userId, defaultAuthority))
: await this.database.observeUser(meta.userId, defaultAuthority, Array.from(userFields))
Object.defineProperty(meta, '$user', { value: user, writable: true })
return user
}
Expand Down

0 comments on commit b0d49f4

Please sign in to comment.