From d0918c06db4009bbfece55692701a3ddb2e47fb6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 8 Oct 2018 00:58:10 +0900 Subject: [PATCH] Fix bug --- src/server/api/stream/index.ts | 2 ++ src/server/api/streaming.ts | 15 +++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/server/api/stream/index.ts b/src/server/api/stream/index.ts index 743d77b2a..ef6397fcd 100644 --- a/src/server/api/stream/index.ts +++ b/src/server/api/stream/index.ts @@ -24,6 +24,7 @@ export default class Connection { public subscriber: Xev; private channels: Channel[] = []; private subscribingNotes: any = {}; + public sendMessageToWsOverride: any = null; // 後方互換性のため constructor( wsConnection: websocket.connection, @@ -164,6 +165,7 @@ export default class Connection { */ @autobind public sendMessageToWs(type: string, payload: any) { + if (this.sendMessageToWsOverride) return this.sendMessageToWsOverride(type, payload); // 後方互換性のため this.wsConnection.send(JSON.stringify({ type: type, body: payload diff --git a/src/server/api/streaming.ts b/src/server/api/streaming.ts index b7793eb28..8bfa5574f 100644 --- a/src/server/api/streaming.ts +++ b/src/server/api/streaming.ts @@ -25,7 +25,7 @@ module.exports = (server: http.Server) => { // 後方互換性のため if (request.resourceURL.pathname !== '/streaming') { - main.sendMessageToWs = (type: string, payload: any) => { + main.sendMessageToWsOverride = (type: string, payload: any) => { if (type == 'channel') { type = payload.type; payload = payload.body; @@ -35,13 +35,12 @@ module.exports = (server: http.Server) => { body: payload })); }; - if (request.resourceURL.pathname === '/') { - main.connectChannel(Math.random().toString(), null, - request.resourceURL.pathname === '/' ? channels.homeTimeline : - request.resourceURL.pathname === '/local-timeline' ? channels.localTimeline : - request.resourceURL.pathname === '/hybrid-timeline' ? channels.hybridTimeline : - request.resourceURL.pathname === '/global-timeline' ? channels.globalTimeline : null); - } + + main.connectChannel(Math.random().toString(), null, + request.resourceURL.pathname === '/' ? channels.homeTimeline : + request.resourceURL.pathname === '/local-timeline' ? channels.localTimeline : + request.resourceURL.pathname === '/hybrid-timeline' ? channels.hybridTimeline : + request.resourceURL.pathname === '/global-timeline' ? channels.globalTimeline : null); } connection.once('close', () => {