Fix UserConfig type in clientManager

This commit is contained in:
Max Leiter 2022-05-31 14:00:59 -07:00
parent 3d4d29bca4
commit c682550e1f
No known key found for this signature in database
GPG key ID: A3512F2F2F17EBDA
4 changed files with 9 additions and 20 deletions

View file

@ -55,7 +55,7 @@ type ClientPushSubscription = {
};
};
type ClientConfig = {
export type UserConfig = {
log: boolean;
password: string;
sessions: {
@ -92,7 +92,7 @@ class Client {
attachedClients!: {
[socketId: string]: {token: string; openChannel: number};
};
config!: ClientConfig & {
config!: UserConfig & {
networks?: Network[];
};
id!: number;
@ -109,7 +109,7 @@ class Client {
fileHash!: string;
constructor(manager: ClientManager, name?: string, config = {} as ClientConfig) {
constructor(manager: ClientManager, name?: string, config = {} as UserConfig) {
_.merge(this, {
awayMessage: "",
lastActiveChannel: -1,

View file

@ -5,7 +5,7 @@ import fs from "fs";
import path from "path";
import Auth from "./plugins/auth";
import Client from "./client";
import Client, {UserConfig} from "./client";
import Config from "./config";
import WebPush from "./plugins/webpush";
import log from "./log";
@ -183,6 +183,7 @@ class ClientManager {
mode: 0o600,
});
} catch (e: any) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
log.error(`Failed to create user ${colors.green(name)} (${e})`);
throw e;
}
@ -250,6 +251,7 @@ class ClientManager {
return callback ? callback() : true;
} catch (e: any) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
log.error(`Failed to update user ${colors.green(client.name)} (${e})`);
if (callback) {
@ -281,8 +283,9 @@ class ClientManager {
try {
const data = fs.readFileSync(userPath, "utf-8");
return JSON.parse(data);
return JSON.parse(data) as UserConfig;
} catch (e: any) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
log.error(`Failed to read user ${colors.bold(name)}: ${e}`);
}

View file

@ -79,20 +79,6 @@ for (const input of builtInInputs) {
});
}
// .reduce(async function (plugins, name) {
// return import(`./${name}`).then(
// (plugin: {
// default: {
// commands: string[];
// input: (network: Network, chan: Chan, cmd: string, args: string[]) => void;
// allowDisconnected?: boolean;
// };
// }) => {
// plugin.default.commands.forEach((command: string) => plugins.set(command, plugin));
// }
// );
// }, Promise.resolve(new Map()));
const pluginCommands = new Map();
const getCommands = () =>

View file

@ -3,6 +3,6 @@
"host": "irc.example.com",
"port": 7000,
"duration": 3600,
"expires": 1654033745673
"expires": 1654034227268
}
]