Merge pull request #2550 from thelounge/xpaw/notice-log

Log notices as correct sender when it will be shown in active window
This commit is contained in:
Jérémie Astori 2018-06-12 19:19:21 -04:00 committed by GitHub
commit 4d17cfb715
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@
const _ = require("lodash"); const _ = require("lodash");
const Helper = require("../helper"); const Helper = require("../helper");
const User = require("./user"); const User = require("./user");
const Msg = require("./msg");
const storage = require("../plugins/storage"); const storage = require("../plugins/storage");
module.exports = Chan; module.exports = Chan;
@ -185,10 +186,20 @@ Chan.prototype.writeUserLog = function(client, msg) {
return; return;
} }
let targetChannel = this;
// Is this particular message or channel loggable // Is this particular message or channel loggable
if (!msg.isLoggable() || !this.isLoggable()) { if (!msg.isLoggable() || !this.isLoggable()) {
// Because notices are nasty and can be shown in active channel on the client
// if there is no open query, we want to always log notices in the sender's name
if (msg.type === Msg.Type.NOTICE && msg.showInActive) {
targetChannel = {
name: msg.from.nick,
};
} else {
return; return;
} }
}
// Find the parent network where this channel is in // Find the parent network where this channel is in
const target = client.find(this.id); const target = client.find(this.id);
@ -198,7 +209,7 @@ Chan.prototype.writeUserLog = function(client, msg) {
} }
for (const messageStorage of client.messageStorage) { for (const messageStorage of client.messageStorage) {
messageStorage.index(target.network, this, msg); messageStorage.index(target.network, targetChannel, msg);
} }
}; };