server: remove some casting to any

This commit is contained in:
Johann150 2023-03-19 10:45:57 +01:00
parent af49f811c1
commit ed9b9210a9
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1
2 changed files with 20 additions and 20 deletions

View file

@ -14,20 +14,20 @@ import hashtag from './hashtag.js';
import channel from './channel.js'; import channel from './channel.js';
import admin from './admin.js'; import admin from './admin.js';
export default { export const channels: Record<string, Channel> = {
main, 'main': main,
homeTimeline, 'homeTimeline': homeTimeline,
localTimeline, 'localTimeline': localTimeline,
hybridTimeline, 'hybridTimeline': hybridTimeline,
globalTimeline, 'globalTimeline': globalTimeline,
serverStats, 'serverStats': serverStats,
queueStats, 'queueStats': queueStats,
userList, 'userList': userList,
antenna, 'antenna': antenna,
messaging, 'messaging': messaging,
messagingIndex, 'messagingIndex': messagingIndex,
drive, 'drive': drive,
hashtag, 'hashtag': hashtag,
channel, 'channel': channel,
admin, 'admin': admin,
}; };

View file

@ -10,7 +10,7 @@ import { publishChannelStream, publishGroupMessagingStream, publishMessagingStre
import { UserGroup } from '@/models/entities/user-group.js'; import { UserGroup } from '@/models/entities/user-group.js';
import { Packed } from '@/misc/schema.js'; import { Packed } from '@/misc/schema.js';
import { readNotification } from '@/server/api/common/read-notification.js'; import { readNotification } from '@/server/api/common/read-notification.js';
import channels from './channels/index.js'; import { channels } from './channels/index.js';
import Channel from './channel.js'; import Channel from './channel.js';
import { StreamEventEmitter, StreamMessages } from './types.js'; import { StreamEventEmitter, StreamMessages } from './types.js';
import Logger from '@/services/logger.js'; import Logger from '@/services/logger.js';
@ -290,16 +290,16 @@ export class Connection {
* *
*/ */
public connectChannel(id: string, params: any, channel: string, pong = false) { public connectChannel(id: string, params: any, channel: string, pong = false) {
if ((channels as any)[channel].requireCredential && this.user == null) { if (channels[channel].requireCredential && this.user == null) {
return; return;
} }
// 共有可能チャンネルに接続しようとしていて、かつそのチャンネルに既に接続していたら無意味なので無視 // 共有可能チャンネルに接続しようとしていて、かつそのチャンネルに既に接続していたら無意味なので無視
if ((channels as any)[channel].shouldShare && this.channels.some(c => c.chName === channel)) { if (channels[channel].shouldShare && this.channels.some(c => c.chName === channel)) {
return; return;
} }
const ch: Channel = new (channels as any)[channel](id, this); const ch: Channel = new channels[channel](id, this);
this.channels.push(ch); this.channels.push(ch);
ch.init(params); ch.init(params);