pull/1/head
yflory 4 years ago
parent 50bec7386d
commit f09ef072ac

@ -334,7 +334,8 @@ const storeMessage = function (Env, channel, msg, isCp, optionalMessageHash, cb)
if (err) { if (err) {
Log.warn("HK_STORE_MESSAGE_INDEX", err.stack); Log.warn("HK_STORE_MESSAGE_INDEX", err.stack);
// non-critical, we'll be able to get the channel index later // non-critical, we'll be able to get the channel index later
// XXX cb with no error so that the message is broadcast // cb with no error so that the message is broadcast
cb();
return void next(); return void next();
} }
if (typeof (index.line) === "number") { index.line++; } if (typeof (index.line) === "number") { index.line++; }
@ -873,7 +874,7 @@ HK.onChannelMessage = function (Env, Server, channel, msgStruct, cb) {
// we should probably just change this to expect a channel id directly // 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 // 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; } // XXX cb no error to broadcast if (!channel.id || channel.id.length === EPHEMERAL_CHANNEL_LENGTH) { return void cb(); }
const isCp = /^cp\|/.test(msgStruct[4]); const isCp = /^cp\|/.test(msgStruct[4]);
let id; let id;
@ -885,7 +886,7 @@ HK.onChannelMessage = function (Env, Server, channel, msgStruct, cb) {
// more straightforward and reliable. // more straightforward and reliable.
if (Array.isArray(id) && id[2] && id[2] === channel.lastSavedCp) { if (Array.isArray(id) && id[2] && id[2] === channel.lastSavedCp) {
// Reject duplicate checkpoints // Reject duplicate checkpoints
return; // XXX cb with error? return void cb('DUPLICATE');
} }
} }
@ -898,7 +899,10 @@ HK.onChannelMessage = function (Env, Server, channel, msgStruct, cb) {
metadata = _metadata; metadata = _metadata;
// don't write messages to expired channels // don't write messages to expired channels
if (checkExpired(Env, Server, channel)) { return void w.abort(); } // XXX cb with error if (checkExpired(Env, Server, channel)) {
cb('EEXPIRED');
return void w.abort();
}
})); }));
}).nThen(function (w) { }).nThen(function (w) {
// if there's no validateKey present skip to the next block // if there's no validateKey present skip to the next block
@ -927,7 +931,8 @@ HK.onChannelMessage = function (Env, Server, channel, msgStruct, cb) {
Log.info("HK_SIGNED_MESSAGE_REJECTED", 'Channel '+channel.id); Log.info("HK_SIGNED_MESSAGE_REJECTED", 'Channel '+channel.id);
} }
// always abort if there was an error... // always abort if there was an error...
return void w.abort(); // XXX cb failed validation cb('FAILED_VALIDATION);
return void w.abort();
}); });
}); });
}).nThen(function () { }).nThen(function () {

Loading…
Cancel
Save