rm CustomChannel

This commit is contained in:
Nick Darrell 2023-08-01 17:41:16 +00:00
parent 1ce0aaf927
commit bea6ab8e09
3 changed files with 8 additions and 30 deletions

View File

@ -1,6 +1,5 @@
import PublicChannel from './channels/types/publicChannel';
import PrivateChannel from './channels/types/privateChannel';
import CustomChannel from './channels/types/customChannel';
import PublicClient from './clients/types/publicClient';
import PrivateClient from './clients/types/privateClient';
import CustomClient from './clients/types/customClient';
@ -17,8 +16,8 @@ class ChannelManager {
}
createChannel(data: any) {
const channelExists: PublicChannel|PrivateChannel|CustomChannel|null = this.channelExists(data.channel);
let channel: PublicChannel|PrivateChannel|CustomChannel;
const channelExists: PublicChannel|PrivateChannel|null = this.channelExists(data.channel);
let channel: PublicChannel|PrivateChannel;
if (channelExists) {
channel = channelExists;
@ -43,7 +42,7 @@ class ChannelManager {
}
addClientToChannel(client: PublicClient|PrivateClient|CustomClient, channel_id: string) {
const channel: PrivateChannel|PrivateChannel|CustomChannel|null = this.channelExists(channel_id);
const channel: PrivateChannel|PrivateChannel|null = this.channelExists(channel_id);
if (channel) {
channel.addClient(client);
@ -54,7 +53,7 @@ class ChannelManager {
}
}
updateChannelContent(channel: PrivateChannel|PrivateChannel|CustomChannel, channelContent: JSON) {
updateChannelContent(channel: PrivateChannel|PrivateChannel, channelContent: JSON) {
if (channel) {
channel.channelContent = channelContent;
return {status: 'success'};
@ -70,12 +69,10 @@ class ChannelManager {
`attempting to create channel of type ${data.channel_type}, channel id: ${data.channel}...`
);
if (data.channel_type === 'public') {
return new PublicChannel(data.channel);
} else if (data.channel_type === 'private') {
if (data.channel_type === 'private') {
return new PrivateChannel(data.channel);
} else {
return new CustomChannel(data.channel, data.custom);
return new PublicChannel(data.channel);
}
} catch (e) {
console.log(e);

View File

@ -1,18 +0,0 @@
import CustomClient from '../../clients/types/customClient';
import ChannelBase from '../channelBase';
class CustomChannel extends ChannelBase {
clients: CustomClient[] = [];
constructor(id: string, custom: any) {
super(id);
if (custom) {
this.broadcastConditions = custom.broadcastConditions;
this.channelContent = custom.channelContent;
this.explicitRemoval = custom.explicitRemoval;
}
}
}
export default CustomChannel;

View File

@ -3,7 +3,6 @@ import ClientManager from '../clientManager';
import ChannelManager from '../channelManager';
import PublicChannel from '../channels/types/publicChannel';
import PrivateChannel from '../channels/types/privateChannel';
import CustomChannel from '../channels/types/customChannel';
const messageManager = require('../messageManager');
const logger = require('../logger');
@ -12,7 +11,7 @@ class ClientBase {
ws: WebSocket;
data: any;
id: number;
channel: PublicChannel|PrivateChannel|CustomChannel|null;
channel: PublicChannel|PrivateChannel|null;
clientManager: ClientManager;
channelManager: ChannelManager;
roles: string[];
@ -68,7 +67,7 @@ class ClientBase {
return this.data.client;
}
connectToChannel(channel: PublicChannel|PrivateChannel|CustomChannel) {
connectToChannel(channel: PublicChannel|PrivateChannel) {
this.channel = channel;
this.ws.on('message', this.messageListener);
this.ws.on('close', this.closeListener);