diff options
| author | anatawa12 <anatawa12@icloud.com> | 2024-07-18 20:04:23 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-18 20:04:23 +0900 |
| commit | 10ce7bf3c45c3e09dc86f1b9c3a0d7e79c23f5ee (patch) | |
| tree | c098b60b4fee0030c4f6502c92035672f3fda44f /packages/backend/src/server/api/stream/channel.ts | |
| parent | fix(frontend): 子メニューの最大長調整が行われていない問... (diff) | |
| download | sharkey-10ce7bf3c45c3e09dc86f1b9c3a0d7e79c23f5ee.tar.gz sharkey-10ce7bf3c45c3e09dc86f1b9c3a0d7e79c23f5ee.tar.bz2 sharkey-10ce7bf3c45c3e09dc86f1b9c3a0d7e79c23f5ee.zip | |
kill any from streaming API Implementation (#14251)
* chore: add JsonValue type
* refactor: kill any from Connection.ts
* refactor: fix StreamEventEmitter contains undefined instead of null
* refactor: kill any from channels
* docs(changelog): Fix: Steaming APIが不正なデータを受けた場合の動作が不安定である問題
* fix license header
* fix lints
Diffstat (limited to 'packages/backend/src/server/api/stream/channel.ts')
| -rw-r--r-- | packages/backend/src/server/api/stream/channel.ts | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/packages/backend/src/server/api/stream/channel.ts b/packages/backend/src/server/api/stream/channel.ts index a267d27fba..84cb552369 100644 --- a/packages/backend/src/server/api/stream/channel.ts +++ b/packages/backend/src/server/api/stream/channel.ts @@ -8,6 +8,7 @@ import { isInstanceMuted } from '@/misc/is-instance-muted.js'; import { isUserRelated } from '@/misc/is-user-related.js'; import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js'; import type { Packed } from '@/misc/json-schema.js'; +import type { JsonObject, JsonValue } from '@/misc/json-value.js'; import type Connection from './Connection.js'; /** @@ -81,10 +82,12 @@ export default abstract class Channel { this.connection = connection; } + public send(payload: { type: string, body: JsonValue }): void + public send(type: string, payload: JsonValue): void @bindThis - public send(typeOrPayload: any, payload?: any) { - const type = payload === undefined ? typeOrPayload.type : typeOrPayload; - const body = payload === undefined ? typeOrPayload.body : payload; + public send(typeOrPayload: { type: string, body: JsonValue } | string, payload?: JsonValue) { + const type = payload === undefined ? (typeOrPayload as { type: string, body: JsonValue }).type : (typeOrPayload as string); + const body = payload === undefined ? (typeOrPayload as { type: string, body: JsonValue }).body : payload; this.connection.sendMessageToWs('channel', { id: this.id, @@ -93,11 +96,11 @@ export default abstract class Channel { }); } - public abstract init(params: any): void; + public abstract init(params: JsonObject): void; public dispose?(): void; - public onMessage?(type: string, body: any): void; + public onMessage?(type: string, body: JsonValue): void; } export type MiChannelService<T extends boolean> = { |