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 admin from './admin.js';
export default {
main,
homeTimeline,
localTimeline,
hybridTimeline,
globalTimeline,
serverStats,
queueStats,
userList,
antenna,
messaging,
messagingIndex,
drive,
hashtag,
channel,
admin,
export const channels: Record<string, Channel> = {
'main': main,
'homeTimeline': homeTimeline,
'localTimeline': localTimeline,
'hybridTimeline': hybridTimeline,
'globalTimeline': globalTimeline,
'serverStats': serverStats,
'queueStats': queueStats,
'userList': userList,
'antenna': antenna,
'messaging': messaging,
'messagingIndex': messagingIndex,
'drive': drive,
'hashtag': hashtag,
'channel': channel,
'admin': admin,
};

View file

@ -10,7 +10,7 @@ import { publishChannelStream, publishGroupMessagingStream, publishMessagingStre
import { UserGroup } from '@/models/entities/user-group.js';
import { Packed } from '@/misc/schema.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 { StreamEventEmitter, StreamMessages } from './types.js';
import Logger from '@/services/logger.js';
@ -290,16 +290,16 @@ export class Connection {
*
*/
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;
}
// 共有可能チャンネルに接続しようとしていて、かつそのチャンネルに既に接続していたら無意味なので無視
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;
}
const ch: Channel = new (channels as any)[channel](id, this);
const ch: Channel = new channels[channel](id, this);
this.channels.push(ch);
ch.init(params);