From 79e5edbdfe62a8af2f3dbffab827076f2682fbe8 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 14 Aug 2019 17:05:18 +0200 Subject: [PATCH] identify classic metadata messages by the presence of a channel attribute --- historyKeeper.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/historyKeeper.js b/historyKeeper.js index 564de6f5f..2a4df62cb 100644 --- a/historyKeeper.js +++ b/historyKeeper.js @@ -291,6 +291,10 @@ module.exports.create = function (cfg) { }); }; + const isMetadataMessage = function (parsed) { + return Boolean(parsed && parsed.channel); + }; + var CHECKPOINT_PATTERN = /^cp\|(([A-Za-z0-9+\/=]+)\|)?/; /* onChannelMessage @@ -514,7 +518,7 @@ module.exports.create = function (cfg) { // and don't send metadata, since: // 1. the user won't be interested in it // 2. this metadata is potentially incomplete/incorrect - if (parsed.channel) { return; } + if (isMetadataMessage(parsed)) { return; } var content = parsed[4]; if (typeof(content) !== 'string') { return; } @@ -713,7 +717,7 @@ module.exports.create = function (cfg) { // check for the channel because it's the one thing that should // always exist in "classic metadata" - if (msg.channel && metadata_cache[channelName]) { return readMore(); } + if (isMetadataMessage(msg) && metadata_cache[channelName]) { return readMore(); } sendMsg(ctx, user, [0, HISTORY_KEEPER_ID, 'MSG', user.id, JSON.stringify(msg)], readMore); }, (err) => { if (err && err.code !== 'ENOENT') {