Skip to content

Commit

Permalink
fix(core): support full event.login, fix content disposition
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 6, 2025
1 parent 719d666 commit a513aa1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export abstract class Bot<C extends Context = Context, T = any> {
const headers = new Headers()
headers.set('content-type', upload.type)
if (upload.filename) {
headers.set('content-disposition', `attachment; filename="${upload.filename}"`)
headers.set('content-disposition', `attachment; filename*=UTF-8''${encodeURIComponent(upload.filename)}`)
}
this.ctx.satori._tempStore[id] = {
status: 200,
Expand Down
7 changes: 2 additions & 5 deletions packages/core/src/session.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Channel, Event, GuildMember, Login, Message, Resource, User } from '@satorijs/protocol'
import { Channel, Event, GuildMember, Message, Resource, User } from '@satorijs/protocol'
import { clone, defineProperty, isNullable } from 'cosmokit'
import { Context, Service } from 'cordis'
import { Bot } from './bot'
Expand Down Expand Up @@ -137,12 +137,9 @@ export class Session<C extends Context = Context> {

toJSON() {
const event: Event = {
login: {
platform: this.platform,
user: { id: this.selfId },
} as Login,
...clone(this.event),
sn: this.sn,
login: this.bot.toJSON(),
['id' as never]: this.sn, // for backward compatibility
}
if (event.message?.elements) {
Expand Down

0 comments on commit a513aa1

Please sign in to comment.