mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-02 05:42:20 +02:00
Replace as string with String constructor
This commit is contained in:
parent
c682550e1f
commit
4f41d80b88
|
@ -242,7 +242,7 @@ class Client {
|
||||||
// Get channel id for lobby before creating other channels for nicer ids
|
// Get channel id for lobby before creating other channels for nicer ids
|
||||||
const lobbyChannelId = client.idChan++;
|
const lobbyChannelId = client.idChan++;
|
||||||
|
|
||||||
if (args.channels) {
|
if (Array.isArray(args.channels)) {
|
||||||
let badName = false;
|
let badName = false;
|
||||||
|
|
||||||
args.channels.forEach((chan: Chan) => {
|
args.channels.forEach((chan: Chan) => {
|
||||||
|
@ -266,7 +266,7 @@ class Client {
|
||||||
"User '" +
|
"User '" +
|
||||||
client.name +
|
client.name +
|
||||||
"' on network '" +
|
"' on network '" +
|
||||||
(args.name as string) +
|
String(args.name) +
|
||||||
"' has an invalid channel which has been ignored"
|
"' has an invalid channel which has been ignored"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -289,12 +289,12 @@ class Client {
|
||||||
|
|
||||||
// TODO; better typing for args
|
// TODO; better typing for args
|
||||||
const network = new Network({
|
const network = new Network({
|
||||||
uuid: args.uuid as string,
|
uuid: String(args.uuid),
|
||||||
name: String(
|
name: String(
|
||||||
args.name || (Config.values.lockNetwork ? Config.values.defaults.name : "") || ""
|
args.name || (Config.values.lockNetwork ? Config.values.defaults.name : "") || ""
|
||||||
),
|
),
|
||||||
host: String(args.host || ""),
|
host: String(args.host || ""),
|
||||||
port: parseInt(args.port as string, 10),
|
port: parseInt(String(args.port), 10),
|
||||||
tls: !!args.tls,
|
tls: !!args.tls,
|
||||||
userDisconnected: !!args.userDisconnected,
|
userDisconnected: !!args.userDisconnected,
|
||||||
rejectUnauthorized: !!args.rejectUnauthorized,
|
rejectUnauthorized: !!args.rejectUnauthorized,
|
||||||
|
|
|
@ -61,7 +61,7 @@ program
|
||||||
log.info("Package(s) have been successfully upgraded.");
|
log.info("Package(s) have been successfully upgraded.");
|
||||||
})
|
})
|
||||||
.catch((code) => {
|
.catch((code) => {
|
||||||
log.error(`Failed to upgrade package(s). Exit code ${code as string}`);
|
log.error(`Failed to upgrade package(s). Exit code ${String(code)}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -230,9 +230,9 @@ class Config {
|
||||||
this.values.fileUpload.baseUrl = undefined;
|
this.values.fileUpload.baseUrl = undefined;
|
||||||
|
|
||||||
log.warn(
|
log.warn(
|
||||||
`The ${colors.bold("fileUpload.baseUrl")} you specified is invalid: ${
|
`The ${colors.bold("fileUpload.baseUrl")} you specified is invalid: ${String(
|
||||||
e as string
|
e
|
||||||
}`
|
)}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ class User {
|
||||||
|
|
||||||
Object.defineProperty(this, "mode", {
|
Object.defineProperty(this, "mode", {
|
||||||
get() {
|
get() {
|
||||||
return (this.modes[0] as string) || "";
|
return String(this.modes[0]);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ function generateAndWrite(folderPath: string, paths: {privateKeyPath: any; certi
|
||||||
|
|
||||||
return certificate;
|
return certificate;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
log.error("Unable to write certificate", e as string);
|
log.error("Unable to write certificate", String(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import {PluginInputHandler} from "./index";
|
import {PluginInputHandler} from "./index";
|
||||||
import Msg, {MessageType} from "../../models/msg";
|
import Msg, {MessageType} from "../../models/msg";
|
||||||
import {ChanType} from "../../models/chan";
|
import Chan, {ChanType} from "../../models/chan";
|
||||||
|
|
||||||
const commands = ["query", "msg", "say"];
|
const commands = ["query", "msg", "say"];
|
||||||
|
|
||||||
function getTarget(cmd, args, chan) {
|
function getTarget(cmd: string, args: string[], chan: Chan) {
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case "msg":
|
case "msg":
|
||||||
case "query":
|
case "query":
|
||||||
|
|
|
@ -180,7 +180,7 @@ export default <IrcEventHandler>function (irc, network) {
|
||||||
new Msg({
|
new Msg({
|
||||||
text: `Disconnected from the network. Reconnecting in ${Math.round(
|
text: `Disconnected from the network. Reconnecting in ${Math.round(
|
||||||
data.wait / 1000
|
data.wait / 1000
|
||||||
)} seconds… (Attempt ${data.attempt})`,
|
)} seconds… (Attempt ${Number(data.attempt)})`,
|
||||||
}),
|
}),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
|
@ -54,7 +54,7 @@ class SqliteMessageStorage implements ISqliteMessageStorage {
|
||||||
try {
|
try {
|
||||||
fs.mkdirSync(logsPath, {recursive: true});
|
fs.mkdirSync(logsPath, {recursive: true});
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
log.error("Unable to create logs directory", e as string);
|
log.error("Unable to create logs directory", String(e));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ class TextFileMessageStorage implements MessageStorage {
|
||||||
try {
|
try {
|
||||||
fs.mkdirSync(logPath, {recursive: true});
|
fs.mkdirSync(logPath, {recursive: true});
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
log.error("Unable to create logs directory", e as string);
|
log.error("Unable to create logs directory", String(e));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,9 +84,9 @@ class WebPush {
|
||||||
WebPushAPI.sendNotification(subscription, JSON.stringify(payload)).catch((error) => {
|
WebPushAPI.sendNotification(subscription, JSON.stringify(payload)).catch((error) => {
|
||||||
if (error.statusCode >= 400 && error.statusCode < 500) {
|
if (error.statusCode >= 400 && error.statusCode < 500) {
|
||||||
log.warn(
|
log.warn(
|
||||||
`WebPush subscription for ${client.name} returned an error (${
|
`WebPush subscription for ${client.name} returned an error (${String(
|
||||||
error.statusCode as string
|
error.statusCode
|
||||||
}), removing subscription`
|
)}), removing subscription`
|
||||||
);
|
);
|
||||||
|
|
||||||
_.forOwn(client.config.sessions, ({pushSubscription}, token) => {
|
_.forOwn(client.config.sessions, ({pushSubscription}, token) => {
|
||||||
|
@ -98,7 +98,7 @@ class WebPush {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.error(`WebPush Error (${error as string})`);
|
log.error(`WebPush Error (${String(error)})`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -344,7 +344,7 @@ function getClientIp(socket: Socket) {
|
||||||
let ip = socket.handshake.address || "127.0.0.1";
|
let ip = socket.handshake.address || "127.0.0.1";
|
||||||
|
|
||||||
if (Config.values.reverseProxy) {
|
if (Config.values.reverseProxy) {
|
||||||
const forwarded = ((socket.handshake.headers["x-forwarded-for"] || "") as string)
|
const forwarded = String(socket.handshake.headers["x-forwarded-for"])
|
||||||
.split(/\s*,\s*/)
|
.split(/\s*,\s*/)
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
|
|
||||||
|
|
1
src/types/modules/irc-framework.d.ts
vendored
1
src/types/modules/irc-framework.d.ts
vendored
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable no-use-before-define */
|
||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
// eslint-disable
|
// eslint-disable
|
||||||
|
|
||||||
|
|
2
test/fixtures/.thelounge/sts-policies.json
vendored
2
test/fixtures/.thelounge/sts-policies.json
vendored
|
@ -3,6 +3,6 @@
|
||||||
"host": "irc.example.com",
|
"host": "irc.example.com",
|
||||||
"port": 7000,
|
"port": 7000,
|
||||||
"duration": 3600,
|
"duration": 3600,
|
||||||
"expires": 1654034227268
|
"expires": 1654034491040
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -178,7 +178,6 @@ describe("Network", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should apply STS policies iff they match", function () {
|
it("should apply STS policies iff they match", function () {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
||||||
const client = {idMsg: 1, emit() {}} as any;
|
const client = {idMsg: 1, emit() {}} as any;
|
||||||
STSPolicies.update("irc.example.com", 7000, 3600);
|
STSPolicies.update("irc.example.com", 7000, 3600);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue