Merge pull request #3549 from thelounge/xpaw/client-setting-awayMessage

Make client awayMessage a client setting
This commit is contained in:
Pavel Djundik 2019-12-03 10:30:21 +02:00 committed by GitHub
commit c260e1a82f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 2 deletions

View File

@ -109,6 +109,21 @@
Show seconds in timestamp Show seconds in timestamp
</label> </label>
</div> </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"> <div class="col-sm-12">
<h2> <h2>
Status messages Status messages

View File

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

View File

@ -45,7 +45,7 @@ const events = [
function Client(manager, name, config = {}) { function Client(manager, name, config = {}) {
_.merge(this, { _.merge(this, {
awayMessage: config.awayMessage || "", awayMessage: "",
lastActiveChannel: -1, lastActiveChannel: -1,
attachedClients: {}, attachedClients: {},
config: config, config: config,
@ -94,6 +94,16 @@ function Client(manager, name, config = {}) {
client.config.browser = {}; 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(); client.compileCustomHighlights();
_.forOwn(client.config.sessions, (session) => { _.forOwn(client.config.sessions, (session) => {

View File

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

View File

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