Revert "network: don't force existence of constructor properties"

This reverts commit 429efb0c3c.
This commit is contained in:
Reto Brunner 2023-03-19 21:58:14 +01:00
parent 30a3ba489a
commit c30da27f95

View file

@ -96,68 +96,71 @@ export type NetworkConfig = {
};
class Network {
nick: string;
name: string;
host: string;
port: number;
tls: boolean;
userDisconnected: boolean;
rejectUnauthorized: boolean;
password: string;
awayMessage: string;
commands: any[];
username: string;
realname: string;
leaveMessage: string;
sasl: string;
saslAccount: string;
saslPassword: string;
channels: Chan[];
uuid: string;
proxyHost: string;
proxyPort: number;
proxyUsername: string;
proxyPassword: string;
proxyEnabled: boolean;
nick!: string;
name!: string;
host!: string;
port!: number;
tls!: boolean;
userDisconnected!: boolean;
rejectUnauthorized!: boolean;
password!: string;
awayMessage!: string;
commands!: any[];
username!: string;
realname!: string;
leaveMessage!: string;
sasl!: string;
saslAccount!: string;
saslPassword!: string;
channels!: Chan[];
uuid!: string;
proxyHost!: string;
proxyPort!: number;
proxyUsername!: string;
proxyPassword!: string;
proxyEnabled!: boolean;
highlightRegex?: RegExp;
irc?: IrcFramework.Client & {
options?: NetworkIrcOptions;
};
chanCache: Chan[];
ignoreList: IgnoreList;
keepNick: string | null;
chanCache!: Chan[];
ignoreList!: IgnoreList;
keepNick!: string | null;
serverOptions: {
status!: NetworkStatus;
serverOptions!: {
CHANTYPES: string[];
PREFIX: Prefix;
NETWORK: string;
};
// TODO: this is only available on export
hasSTSPolicy: boolean;
status: NetworkStatus;
hasSTSPolicy!: boolean;
constructor(attr?: Partial<Network>) {
this.name = "";
this.nick = "";
this.host = "";
this.port = 6667;
this.tls = false;
this.userDisconnected = false;
this.rejectUnauthorized = false;
this.password = "";
this.awayMessage = "";
this.commands = [];
this.username = "";
this.realname = "";
this.leaveMessage = "";
this.sasl = "";
this.saslAccount = "";
this.saslPassword = "";
this.channels = [];
this.serverOptions = {
_.defaults(this, attr, {
name: "",
nick: "",
host: "",
port: 6667,
tls: false,
userDisconnected: false,
rejectUnauthorized: false,
password: "",
awayMessage: "",
commands: [],
username: "",
realname: "",
leaveMessage: "",
sasl: "",
saslAccount: "",
saslPassword: "",
channels: [],
irc: null,
serverOptions: {
CHANTYPES: ["#", "&"],
PREFIX: new Prefix([
{symbol: "!", mode: "Y"},
@ -166,26 +169,20 @@ class Network {
{symbol: "+", mode: "v"},
]),
NETWORK: "",
};
this.proxyHost = "";
this.proxyPort = 1080;
this.proxyUsername = "";
this.proxyPassword = "";
this.proxyEnabled = false;
},
this.chanCache = [];
this.ignoreList = [];
this.keepNick = null;
this.hasSTSPolicy = false;
this.uuid = "invalid"; // sentinel value that makes us generate a new one
proxyHost: "",
proxyPort: 1080,
proxyUsername: "",
proxyPassword: "",
proxyEnabled: false,
this.status = {connected: false, secure: false};
chanCache: [],
ignoreList: [],
keepNick: null,
});
if (attr) {
Object.assign(this, attr);
}
if (this.uuid === "invalid" || !this.uuid) {
if (!this.uuid) {
this.uuid = uuidv4();
}