From 50bec7386db89cfb5a3c5e52a783b6ed2e7a95d4 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 16 Feb 2021 19:25:47 +0530 Subject: [PATCH] flag logic that is missing callbacks --- lib/hk-util.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/hk-util.js b/lib/hk-util.js index 2872b802d..d63ff1b75 100644 --- a/lib/hk-util.js +++ b/lib/hk-util.js @@ -334,6 +334,7 @@ const storeMessage = function (Env, channel, msg, isCp, optionalMessageHash, cb) if (err) { Log.warn("HK_STORE_MESSAGE_INDEX", err.stack); // non-critical, we'll be able to get the channel index later + // XXX cb with no error so that the message is broadcast return void next(); } if (typeof (index.line) === "number") { index.line++; } @@ -872,7 +873,7 @@ HK.onChannelMessage = function (Env, Server, channel, msgStruct, cb) { // we should probably just change this to expect a channel id directly // don't store messages if the channel id indicates that it's an ephemeral message - if (!channel.id || channel.id.length === EPHEMERAL_CHANNEL_LENGTH) { return; } + if (!channel.id || channel.id.length === EPHEMERAL_CHANNEL_LENGTH) { return; } // XXX cb no error to broadcast const isCp = /^cp\|/.test(msgStruct[4]); let id; @@ -884,7 +885,7 @@ HK.onChannelMessage = function (Env, Server, channel, msgStruct, cb) { // more straightforward and reliable. if (Array.isArray(id) && id[2] && id[2] === channel.lastSavedCp) { // Reject duplicate checkpoints - return; + return; // XXX cb with error? } } @@ -897,7 +898,7 @@ HK.onChannelMessage = function (Env, Server, channel, msgStruct, cb) { metadata = _metadata; // don't write messages to expired channels - if (checkExpired(Env, Server, channel)) { return void w.abort(); } + if (checkExpired(Env, Server, channel)) { return void w.abort(); } // XXX cb with error })); }).nThen(function (w) { // if there's no validateKey present skip to the next block @@ -926,7 +927,7 @@ HK.onChannelMessage = function (Env, Server, channel, msgStruct, cb) { Log.info("HK_SIGNED_MESSAGE_REJECTED", 'Channel '+channel.id); } // always abort if there was an error... - return void w.abort(); + return void w.abort(); // XXX cb failed validation }); }); }).nThen(function () {