Skip to content

Commit

Permalink
fix(satori): call internal api bugs (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgc2333 authored Apr 7, 2024
1 parent 57e1617 commit ac6d163
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion adapters/satori/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export function transformKey(source: any, callback: (key: string) => string) {
function createInternal(bot: SatoriBot, prefix = '') {
return new Proxy(() => {}, {
apply(target, thisArg, args) {
return bot.http.post('/internal/' + snakeCase(prefix.slice(1)), args)
const key = snakeCase(prefix.slice(1))
bot.logger.debug("[request.internal]", key, args)

Check failure on line 16 in adapters/satori/src/bot.ts

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote
return bot.http.post('/v1/internal/' + key, args)
},
get(target, key, receiver) {
if (typeof key === 'symbol' || key in target) {
Expand Down
4 changes: 2 additions & 2 deletions packages/server-satori/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ export function apply(ctx: Context, config: Config) {
})

ctx.server.post(path + '/v1/internal/:name', async (koa) => {
const selfId = koa.request.headers['X-Self-ID']
const platform = koa.request.headers['X-Platform']
const selfId = koa.request.headers['x-self-id']
const platform = koa.request.headers['x-platform']
const bot = ctx.bots.find(bot => bot.selfId === selfId && bot.platform === platform)
if (!bot) {
koa.body = 'bot not found'
Expand Down

0 comments on commit ac6d163

Please sign in to comment.