Fix away message disappearing

Closes #1102
This commit is contained in:
Pavel Djundik 2017-04-28 18:58:14 +03:00
parent 5eb5b99115
commit d6d7df62fe
3 changed files with 7 additions and 4 deletions

View file

@ -66,8 +66,9 @@ function Client(manager, name, config) {
if (typeof config !== "object") {
config = {};
}
_.merge(this, {
awayMessage: "",
awayMessage: config.awayMessage || "",
lastActiveChannel: -1,
attachedClients: {},
config: config,
@ -482,8 +483,6 @@ Client.prototype.clientAttach = function(socketId) {
var client = this;
var save = false;
client.attachedClients[socketId] = client.lastActiveChannel;
if (client.awayMessage && _.size(client.attachedClients) === 0) {
client.networks.forEach(function(network) {
// Only remove away on client attachment if
@ -494,6 +493,8 @@ Client.prototype.clientAttach = function(socketId) {
});
}
client.attachedClients[socketId] = client.lastActiveChannel;
// Update old networks to store ip and hostmask
client.networks.forEach(network => {
if (!network.ip) {
@ -539,7 +540,6 @@ Client.prototype.save = _.debounce(function SaveClient() {
const client = this;
let json = {};
json.awayMessage = client.awayMessage;
json.networks = this.networks.map(n => n.export());
client.manager.updateUser(client.name, json);
}, 1000, {maxWait: 10000});

View file

@ -104,6 +104,7 @@ ClientManager.prototype.addUser = function(name, password, enableLog) {
user: name,
password: password || "",
log: enableLog,
awayMessage: "",
networks: []
};
fs.writeFileSync(

View file

@ -14,4 +14,6 @@ exports.input = function(network, chan, cmd, args) {
}
network.awayMessage = reason;
this.save();
};