flag logic that is missing callbacks

This commit is contained in:
ansuz 2021-02-16 19:25:47 +05:30
parent 287b80d4b8
commit 50bec7386d

View file

@ -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 () {