mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-15 20:15:11 +02:00
Enable setting network commands on network creation
This commit is contained in:
parent
9dbb6e5e19
commit
e4e57b00c0
|
@ -252,7 +252,18 @@
|
|||
placeholder="The Lounge - https://thelounge.chat"
|
||||
/>
|
||||
</div>
|
||||
<template v-if="defaults.uuid && !$store.state.serverConfiguration.public">
|
||||
<template v-if="!defaults.uuid">
|
||||
<div class="connect-row">
|
||||
<label for="connect:channels">Channels</label>
|
||||
<input
|
||||
id="connect:channels"
|
||||
v-model="defaults.join"
|
||||
class="input"
|
||||
name="join"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="!$store.state.serverConfiguration.public">
|
||||
<div class="connect-row">
|
||||
<label for="connect:commands">
|
||||
Commands
|
||||
|
@ -260,7 +271,7 @@
|
|||
class="tooltipped tooltipped-ne tooltipped-no-delay"
|
||||
aria-label="One /command per line.
|
||||
Each command will be executed in
|
||||
the server tab on new connection"
|
||||
the server tab on every connection."
|
||||
>
|
||||
<button class="extra-help" />
|
||||
</span>
|
||||
|
@ -276,17 +287,6 @@ the server tab on new connection"
|
|||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="!defaults.uuid">
|
||||
<div class="connect-row">
|
||||
<label for="connect:channels">Channels</label>
|
||||
<input
|
||||
id="connect:channels"
|
||||
v-model="defaults.join"
|
||||
class="input"
|
||||
name="join"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-if="$store.state.serverConfiguration.public">
|
||||
<template v-if="config.lockNetwork">
|
||||
|
|
|
@ -22,6 +22,18 @@ const fieldsForClient = {
|
|||
serverOptions: true,
|
||||
};
|
||||
|
||||
const parseCommands = function (commands) {
|
||||
if (!commands) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Split commands into an array
|
||||
return commands
|
||||
.replace(/\r\n|\r|\n/g, "\n")
|
||||
.split("\n")
|
||||
.filter((command) => command.length > 0);
|
||||
};
|
||||
|
||||
function Network(attr) {
|
||||
_.defaults(this, attr, {
|
||||
name: "",
|
||||
|
@ -83,6 +95,10 @@ function Network(attr) {
|
|||
this.channels.every((chan) => chan.muted || chan.type === Chan.Type.SPECIAL),
|
||||
})
|
||||
);
|
||||
|
||||
if (this.commands && !Array.isArray(this.commands)) {
|
||||
this.commands = parseCommands(this.commands);
|
||||
}
|
||||
}
|
||||
|
||||
Network.prototype.validate = function (client) {
|
||||
|
@ -298,10 +314,7 @@ Network.prototype.edit = function (client, args) {
|
|||
this.proxyEnabled = !!args.proxyEnabled;
|
||||
|
||||
// Split commands into an array
|
||||
this.commands = String(args.commands || "")
|
||||
.replace(/\r\n|\r|\n/g, "\n")
|
||||
.split("\n")
|
||||
.filter((command) => command.length > 0);
|
||||
this.commands = parseCommands(String(args.commands || ""));
|
||||
|
||||
// Sync lobby channel name
|
||||
this.channels[0].name = this.name;
|
||||
|
|
|
@ -395,9 +395,12 @@ function initializeClient(socket, client, token, lastMessage, openChannel) {
|
|||
if (_.isPlainObject(data)) {
|
||||
// prevent people from overriding webirc settings
|
||||
data.uuid = null;
|
||||
data.commands = null;
|
||||
data.ignoreList = null;
|
||||
|
||||
if (Helper.config.webirc !== null) {
|
||||
data.commands = null;
|
||||
}
|
||||
|
||||
client.connect(data);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue