From 033bd361f942965edac1f5b449d403d5a5a4ed38 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 21 Feb 2020 13:58:21 -0500 Subject: [PATCH] add backwards compatibility with older servers --- lib/historyKeeper.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/historyKeeper.js b/lib/historyKeeper.js index 12c9762e5..7cf6dad00 100644 --- a/lib/historyKeeper.js +++ b/lib/historyKeeper.js @@ -116,16 +116,22 @@ module.exports.create = function (config, cb) { channelOpen: function (Server, channelName, userId, wait) { Env.channel_cache[channelName] = Env.channel_cache[channelName] || {}; + var sendHKJoinMessage = function () { + Server.send(userId, [ + 0, + Env.id, + 'JOIN', + channelName + ]); + }; + + // a little backwards compatibility in case you don't have the latest server + // allow lists won't work unless you update, though + if (typeof(wait) !== 'function') { return void sendHKJoinMessage(); } + var next = wait(); var cb = function (err, info) { - next(err, info, function () { - Server.send(userId, [ - 0, - Env.id, - 'JOIN', - channelName - ]); - }); + next(err, info, sendHKJoinMessage); }; // only conventional channels can be restricted