From 148be767bb9b9fad05f1db5bc711c7ec52e98338 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Tue, 19 Apr 2016 13:28:07 +0300 Subject: [PATCH] Fix #232: Do not store messages in memory when running in public mode --- src/models/chan.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/models/chan.js b/src/models/chan.js index 6b81cf75..6bcf51b2 100644 --- a/src/models/chan.js +++ b/src/models/chan.js @@ -26,16 +26,22 @@ function Chan(attr) { } Chan.prototype.pushMessage = function(client, msg) { + client.emit("msg", { + chan: this.id, + msg: msg + }); + + // Never store messages in public mode as the session + // is completely destroyed when the page gets closed + if (config.public) { + return; + } + this.messages.push(msg); if (config.maxHistory >= 0 && this.messages.length > config.maxHistory) { this.messages.splice(0, this.messages.length - config.maxHistory); } - - client.emit("msg", { - chan: this.id, - msg: msg - }); }; Chan.prototype.sortUsers = function(irc) {