Merge pull request #1104 from thelounge/xpaw/fix-autoaway
Fix away message disappearing
This commit is contained in:
commit
26ccd2f1f8
@ -66,8 +66,9 @@ function Client(manager, name, config) {
|
|||||||
if (typeof config !== "object") {
|
if (typeof config !== "object") {
|
||||||
config = {};
|
config = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
_.merge(this, {
|
_.merge(this, {
|
||||||
awayMessage: "",
|
awayMessage: config.awayMessage || "",
|
||||||
lastActiveChannel: -1,
|
lastActiveChannel: -1,
|
||||||
attachedClients: {},
|
attachedClients: {},
|
||||||
config: config,
|
config: config,
|
||||||
@ -482,8 +483,6 @@ Client.prototype.clientAttach = function(socketId) {
|
|||||||
var client = this;
|
var client = this;
|
||||||
var save = false;
|
var save = false;
|
||||||
|
|
||||||
client.attachedClients[socketId] = client.lastActiveChannel;
|
|
||||||
|
|
||||||
if (client.awayMessage && _.size(client.attachedClients) === 0) {
|
if (client.awayMessage && _.size(client.attachedClients) === 0) {
|
||||||
client.networks.forEach(function(network) {
|
client.networks.forEach(function(network) {
|
||||||
// Only remove away on client attachment if
|
// 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
|
// Update old networks to store ip and hostmask
|
||||||
client.networks.forEach(network => {
|
client.networks.forEach(network => {
|
||||||
if (!network.ip) {
|
if (!network.ip) {
|
||||||
@ -539,7 +540,6 @@ Client.prototype.save = _.debounce(function SaveClient() {
|
|||||||
|
|
||||||
const client = this;
|
const client = this;
|
||||||
let json = {};
|
let json = {};
|
||||||
json.awayMessage = client.awayMessage;
|
|
||||||
json.networks = this.networks.map(n => n.export());
|
json.networks = this.networks.map(n => n.export());
|
||||||
client.manager.updateUser(client.name, json);
|
client.manager.updateUser(client.name, json);
|
||||||
}, 1000, {maxWait: 10000});
|
}, 1000, {maxWait: 10000});
|
||||||
|
@ -104,6 +104,7 @@ ClientManager.prototype.addUser = function(name, password, enableLog) {
|
|||||||
user: name,
|
user: name,
|
||||||
password: password || "",
|
password: password || "",
|
||||||
log: enableLog,
|
log: enableLog,
|
||||||
|
awayMessage: "",
|
||||||
networks: []
|
networks: []
|
||||||
};
|
};
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
|
@ -14,4 +14,6 @@ exports.input = function(network, chan, cmd, args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
network.awayMessage = reason;
|
network.awayMessage = reason;
|
||||||
|
|
||||||
|
this.save();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user