make validation of channel options more strict in GET_HISTORY

This commit is contained in:
ansuz 2019-08-14 17:10:40 +02:00
parent 79e5edbdfe
commit 1e2a6405d0

View File

@ -581,7 +581,8 @@ module.exports.create = function (cfg) {
// If it is, remove it from memory and broadcast a message to its members // If it is, remove it from memory and broadcast a message to its members
const onChannelMetadataChanged = function (ctx, channel) { const onChannelMetadataChanged = function (ctx, channel) {
// XXX // XXX lint compliance
channel = channel;
}; };
/* checkExpired /* checkExpired
@ -653,9 +654,10 @@ module.exports.create = function (cfg) {
var lastKnownHash = parsed[3]; var lastKnownHash = parsed[3];
var owners; var owners;
var expire; var expire;
// XXX we can be a bit more strict in our validation here // clients can optionally pass a map of attributes
// maybe we should check that it's an object and not an array? // if the channel already exists this map will be ignored
if (parsed[2] && typeof parsed[2] === "object") { // otherwise it will be stored as the initial metadata state for the channel
if (parsed[2] && typeof(parsed[2]) === "object" && !Array.isArray(parsed[2])) {
validateKey = parsed[2].validateKey; validateKey = parsed[2].validateKey;
lastKnownHash = parsed[2].lastKnownHash; lastKnownHash = parsed[2].lastKnownHash;
owners = parsed[2].owners; owners = parsed[2].owners;