mirror of
https://github.com/thelounge/thelounge
synced 2024-11-14 16:27:22 +00:00
parent
676cc01203
commit
79eb83d82f
2 changed files with 16 additions and 18 deletions
|
@ -5,7 +5,6 @@ var colors = require("colors/safe");
|
|||
var pkg = require("../package.json");
|
||||
var Chan = require("./models/chan");
|
||||
var crypto = require("crypto");
|
||||
var userLog = require("./userLog");
|
||||
var Msg = require("./models/msg");
|
||||
var Network = require("./models/network");
|
||||
var ircFramework = require("irc-framework");
|
||||
|
@ -114,23 +113,6 @@ Client.prototype.emit = function(event, data) {
|
|||
if (this.sockets !== null) {
|
||||
this.sockets.in(this.id).emit(event, data);
|
||||
}
|
||||
if (this.config.log === true) {
|
||||
if (event === "msg") {
|
||||
var target = this.find(data.chan);
|
||||
if (target) {
|
||||
var chan = target.chan.name;
|
||||
if (target.chan.type === Chan.Type.LOBBY) {
|
||||
chan = target.network.host;
|
||||
}
|
||||
userLog.write(
|
||||
this.name,
|
||||
target.network.host,
|
||||
chan,
|
||||
data.msg
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Client.prototype.find = function(channelId) {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
var _ = require("lodash");
|
||||
var Helper = require("../helper");
|
||||
const userLog = require("../userLog");
|
||||
const storage = require("../plugins/storage");
|
||||
|
||||
module.exports = Chan;
|
||||
|
@ -57,6 +58,10 @@ Chan.prototype.pushMessage = function(client, msg, increasesUnread) {
|
|||
|
||||
this.messages.push(msg);
|
||||
|
||||
if (client.config.log === true) {
|
||||
writeUserLog(client, msg);
|
||||
}
|
||||
|
||||
if (Helper.config.maxHistory >= 0 && this.messages.length > Helper.config.maxHistory) {
|
||||
const deleted = this.messages.splice(0, this.messages.length - Helper.config.maxHistory);
|
||||
|
||||
|
@ -127,3 +132,14 @@ Chan.prototype.toJSON = function() {
|
|||
clone.messages = clone.messages.slice(-100);
|
||||
return clone;
|
||||
};
|
||||
|
||||
function writeUserLog(client, msg) {
|
||||
const target = client.find(this.id);
|
||||
|
||||
userLog.write(
|
||||
client.name,
|
||||
target.network.host, // TODO: Fix #1392, multiple connections to same server results in duplicate logs
|
||||
this.type === Chan.Type.LOBBY ? target.network.host : this.name,
|
||||
msg
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue