mirror of
https://github.com/thelounge/thelounge.git
synced 2026-03-14 14:35:50 +01:00
Fix load of channels from user config
While the commits that caused the problem have been reverted, this still adds test cases to it and make the loading more robust.
This commit is contained in:
commit
90ad06a29a
2 changed files with 119 additions and 7 deletions
|
|
@ -6,7 +6,7 @@ import crypto from "crypto";
|
|||
import colors from "chalk";
|
||||
|
||||
import log from "./log";
|
||||
import Chan, {Channel, ChanType} from "./models/chan";
|
||||
import Chan, {ChanConfig, Channel, ChanType} from "./models/chan";
|
||||
import Msg, {MessageType, UserInMessage} from "./models/msg";
|
||||
import Config from "./config";
|
||||
import {condensedTypes} from "../shared/irc";
|
||||
|
|
@ -251,11 +251,13 @@ class Client {
|
|||
let channels: Chan[] = [];
|
||||
|
||||
if (Array.isArray(args.channels)) {
|
||||
let badName = false;
|
||||
let badChanConf = false;
|
||||
|
||||
args.channels.forEach((chan: Chan) => {
|
||||
if (!chan.name) {
|
||||
badName = true;
|
||||
args.channels.forEach((chan: ChanConfig) => {
|
||||
const type = ChanType[(chan.type || "channel").toUpperCase()];
|
||||
|
||||
if (!chan.name || !type) {
|
||||
badChanConf = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -263,13 +265,13 @@ class Client {
|
|||
client.createChannel({
|
||||
name: chan.name,
|
||||
key: chan.key || "",
|
||||
type: chan.type,
|
||||
type: type,
|
||||
muted: chan.muted,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
if (badName && client.name) {
|
||||
if (badChanConf && client.name) {
|
||||
log.warn(
|
||||
"User '" +
|
||||
client.name +
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue