Make client awayMessage a client setting

This commit is contained in:
Pavel Djundik 2019-03-11 19:25:02 +02:00
parent d90a81240f
commit 3dae767937
5 changed files with 36 additions and 2 deletions

View File

@ -109,6 +109,21 @@
Show seconds in timestamp
</label>
</div>
<div v-if="$store.state.settings.advanced" class="col-sm-12">
<h2>Automatic away message</h2>
<label class="opt">
<label for="awayMessage" class="sr-only">Automatic away message</label>
<input
id="awayMessage"
:value="$store.state.settings.awayMessage"
type="text"
name="awayMessage"
class="input"
placeholder="Away message if The Lounge is not open"
/>
</label>
</div>
<div class="col-sm-12">
<h2>
Status messages

View File

@ -44,6 +44,10 @@ export const config = normalizeConfig({
default: "",
sync: "always",
},
awayMessage: {
default: "",
sync: "always",
},
links: {
default: true,
},

View File

@ -45,7 +45,7 @@ const events = [
function Client(manager, name, config = {}) {
_.merge(this, {
awayMessage: config.awayMessage || "",
awayMessage: "",
lastActiveChannel: -1,
attachedClients: {},
config: config,
@ -94,6 +94,16 @@ function Client(manager, name, config = {}) {
client.config.browser = {};
}
// TODO: Backwards compatibility with older versions, remove in a future release?
if (client.config.awayMessage) {
client.config.clientSettings.awayMessage = client.config.awayMessage;
delete client.config.awayMessage;
}
if (client.config.clientSettings.awayMessage) {
client.awayMessage = client.config.clientSettings.awayMessage;
}
client.compileCustomHighlights();
_.forOwn(client.config.sessions, (session) => {

View File

@ -134,7 +134,6 @@ ClientManager.prototype.addUser = function(name, password, enableLog) {
const user = {
password: password || "",
log: enableLog,
awayMessage: "",
networks: [],
sessions: {},
clientSettings: {},

View File

@ -593,6 +593,12 @@ function initializeClient(socket, client, token, lastMessage, openChannel) {
if (newSetting.name === "highlights") {
client.compileCustomHighlights();
} else if (newSetting.name === "awayMessage") {
if (typeof newSetting.value !== "string") {
newSetting.value = "";
}
client.awayMessage = newSetting.value;
}
}
});