exclude invalid channel and blob ids when fetching your channel list

for all variations of the same API
This commit is contained in:
ansuz 2021-08-10 18:51:00 +05:30
parent b9eced7bfd
commit d8af3a16ab

View File

@ -1167,6 +1167,13 @@ define([
Store Store
*/ */
var excludeInvalidIdentifiers = function (result) {
return result.filter(function (channel) {
if (typeof(channel) !== 'string') { return; }
return [32, 48].indexOf(channel.length) !== -1;
});
};
// Get the list of channels filtered by a type (expirable channels, owned channels, pin list) // Get the list of channels filtered by a type (expirable channels, owned channels, pin list)
var getChannelsList = function (Env, type) { var getChannelsList = function (Env, type) {
var result = []; var result = [];
@ -1228,8 +1235,8 @@ define([
} }
}; };
if (type === 'owned' && !Env.edPublic) { return result; } if (type === 'owned' && !Env.edPublic) { return excludeInvalidIdentifiers(result); }
if (type === 'pin' && !Env.edPublic) { return result; } if (type === 'pin' && !Env.edPublic) { return excludeInvalidIdentifiers(result); }
// Get the list of user objects // Get the list of user objects
var userObjects = _getUserObjects(Env); var userObjects = _getUserObjects(Env);
@ -1256,10 +1263,7 @@ define([
Array.prototype.push.apply(result, sfChannels); Array.prototype.push.apply(result, sfChannels);
} }
return result.filter(function (channel) { return excludeInvalidIdentifiers(result);
if (typeof(channel) !== 'string') { return; }
return [32, 48].indexOf(channel.length) !== -1;
});
}; };
var addPad = function (Env, path, pad, cb) { var addPad = function (Env, path, pad, cb) {