mirror of
https://github.com/thelounge/thelounge
synced 2024-11-22 20:13:07 +00:00
network: don't force existence of constructor properties
This commit is contained in:
parent
f785acb07d
commit
429efb0c3c
1 changed files with 72 additions and 69 deletions
|
@ -68,93 +68,96 @@ export type NetworkWithIrcFramework = Network & {
|
||||||
};
|
};
|
||||||
|
|
||||||
class Network {
|
class Network {
|
||||||
nick!: string;
|
nick: string;
|
||||||
name!: string;
|
name: string;
|
||||||
host!: string;
|
host: string;
|
||||||
port!: number;
|
port: number;
|
||||||
tls!: boolean;
|
tls: boolean;
|
||||||
userDisconnected!: boolean;
|
userDisconnected: boolean;
|
||||||
rejectUnauthorized!: boolean;
|
rejectUnauthorized: boolean;
|
||||||
password!: string;
|
password: string;
|
||||||
awayMessage!: string;
|
awayMessage: string;
|
||||||
commands!: any[];
|
commands: any[];
|
||||||
username!: string;
|
username: string;
|
||||||
realname!: string;
|
realname: string;
|
||||||
leaveMessage!: string;
|
leaveMessage: string;
|
||||||
sasl!: string;
|
sasl: string;
|
||||||
saslAccount!: string;
|
saslAccount: string;
|
||||||
saslPassword!: string;
|
saslPassword: string;
|
||||||
channels!: Chan[];
|
channels: Chan[];
|
||||||
uuid!: string;
|
uuid: string;
|
||||||
proxyHost!: string;
|
proxyHost: string;
|
||||||
proxyPort!: number;
|
proxyPort: number;
|
||||||
proxyUsername!: string;
|
proxyUsername: string;
|
||||||
proxyPassword!: string;
|
proxyPassword: string;
|
||||||
proxyEnabled!: boolean;
|
proxyEnabled: boolean;
|
||||||
highlightRegex?: RegExp;
|
highlightRegex?: RegExp;
|
||||||
|
|
||||||
irc?: IrcFramework.Client & {
|
irc?: IrcFramework.Client & {
|
||||||
options?: NetworkIrcOptions;
|
options?: NetworkIrcOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
chanCache!: Chan[];
|
chanCache: Chan[];
|
||||||
ignoreList!: IgnoreList;
|
ignoreList: IgnoreList;
|
||||||
keepNick!: string | null;
|
keepNick: string | null;
|
||||||
|
|
||||||
status!: NetworkStatus;
|
serverOptions: {
|
||||||
|
|
||||||
serverOptions!: {
|
|
||||||
CHANTYPES: string[];
|
CHANTYPES: string[];
|
||||||
PREFIX: Prefix;
|
PREFIX: Prefix;
|
||||||
NETWORK: string;
|
NETWORK: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: this is only available on export
|
// TODO: this is only available on export
|
||||||
hasSTSPolicy!: boolean;
|
hasSTSPolicy: boolean;
|
||||||
|
status: NetworkStatus;
|
||||||
|
|
||||||
constructor(attr?: Partial<Network>) {
|
constructor(attr?: Partial<Network>) {
|
||||||
_.defaults(this, attr, {
|
this.name = "";
|
||||||
name: "",
|
this.nick = "";
|
||||||
nick: "",
|
this.host = "";
|
||||||
host: "",
|
this.port = 6667;
|
||||||
port: 6667,
|
this.tls = false;
|
||||||
tls: false,
|
this.userDisconnected = false;
|
||||||
userDisconnected: false,
|
this.rejectUnauthorized = false;
|
||||||
rejectUnauthorized: false,
|
this.password = "";
|
||||||
password: "",
|
this.awayMessage = "";
|
||||||
awayMessage: "",
|
this.commands = [];
|
||||||
commands: [],
|
this.username = "";
|
||||||
username: "",
|
this.realname = "";
|
||||||
realname: "",
|
this.leaveMessage = "";
|
||||||
leaveMessage: "",
|
this.sasl = "";
|
||||||
sasl: "",
|
this.saslAccount = "";
|
||||||
saslAccount: "",
|
this.saslPassword = "";
|
||||||
saslPassword: "",
|
this.channels = [];
|
||||||
channels: [],
|
this.serverOptions = {
|
||||||
irc: null,
|
CHANTYPES: ["#", "&"],
|
||||||
serverOptions: {
|
PREFIX: new Prefix([
|
||||||
CHANTYPES: ["#", "&"],
|
{symbol: "!", mode: "Y"},
|
||||||
PREFIX: new Prefix([
|
{symbol: "@", mode: "o"},
|
||||||
{symbol: "!", mode: "Y"},
|
{symbol: "%", mode: "h"},
|
||||||
{symbol: "@", mode: "o"},
|
{symbol: "+", mode: "v"},
|
||||||
{symbol: "%", mode: "h"},
|
]),
|
||||||
{symbol: "+", mode: "v"},
|
NETWORK: "",
|
||||||
]),
|
};
|
||||||
NETWORK: "",
|
this.proxyHost = "";
|
||||||
},
|
this.proxyPort = 1080;
|
||||||
|
this.proxyUsername = "";
|
||||||
|
this.proxyPassword = "";
|
||||||
|
this.proxyEnabled = false;
|
||||||
|
|
||||||
proxyHost: "",
|
this.chanCache = [];
|
||||||
proxyPort: 1080,
|
this.ignoreList = [];
|
||||||
proxyUsername: "",
|
this.keepNick = null;
|
||||||
proxyPassword: "",
|
this.hasSTSPolicy = false;
|
||||||
proxyEnabled: false,
|
this.uuid = "invalid"; // sentinel value that makes us generate a new one
|
||||||
|
|
||||||
chanCache: [],
|
this.status = {connected: false, secure: false};
|
||||||
ignoreList: [],
|
|
||||||
keepNick: null,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!this.uuid) {
|
if (attr) {
|
||||||
|
Object.assign(this, attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.uuid === "invalid" || !this.uuid) {
|
||||||
this.uuid = uuidv4();
|
this.uuid = uuidv4();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue