|
|
@ -54,16 +54,8 @@ Channel.clearOwnedChannel = function (Env, safeKey, channelId, cb, Server) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Channel.removeOwnedChannel = function (Env, safeKey, channelId, cb, Server) {
|
|
|
|
var archiveOwnedChannel = function (Env, safeKey, channelId, cb, Server) {
|
|
|
|
if (typeof(channelId) !== 'string' || !Core.isValidId(channelId)) {
|
|
|
|
|
|
|
|
return cb('INVALID_ARGUMENTS');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var unsafeKey = Util.unescapeKeyCharacters(safeKey);
|
|
|
|
var unsafeKey = Util.unescapeKeyCharacters(safeKey);
|
|
|
|
|
|
|
|
|
|
|
|
if (Env.blobStore.isFileId(channelId)) {
|
|
|
|
|
|
|
|
return void Env.removeOwnedBlob(channelId, safeKey, cb);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Metadata.getMetadata(Env, channelId, function (err, metadata) {
|
|
|
|
Metadata.getMetadata(Env, channelId, function (err, metadata) {
|
|
|
|
if (err) { return void cb(err); }
|
|
|
|
if (err) { return void cb(err); }
|
|
|
|
if (!Core.hasOwners(metadata)) { return void cb('E_NO_OWNERS'); }
|
|
|
|
if (!Core.hasOwners(metadata)) { return void cb('E_NO_OWNERS'); }
|
|
|
@ -124,6 +116,24 @@ Channel.removeOwnedChannel = function (Env, safeKey, channelId, cb, Server) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Channel.removeOwnedChannel = function (Env, safeKey, channelId, __cb, Server) {
|
|
|
|
|
|
|
|
var _cb = Util.once(Util.mkAsync(__cb));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (typeof(channelId) !== 'string' || !Core.isValidId(channelId)) {
|
|
|
|
|
|
|
|
return _cb('INVALID_ARGUMENTS');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// archiving large channels or files can be expensive, so do it one at a time
|
|
|
|
|
|
|
|
// for any given user to ensure that nobody can use too much of the server's resources
|
|
|
|
|
|
|
|
Env.queueDeletes(safeKey, function (next) {
|
|
|
|
|
|
|
|
var cb = Util.both(_cb, next);
|
|
|
|
|
|
|
|
if (Env.blobStore.isFileId(channelId)) {
|
|
|
|
|
|
|
|
return void Env.removeOwnedBlob(channelId, safeKey, cb);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
archiveOwnedChannel(Env, safeKey, channelId, cb, Server);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Channel.trimHistory = function (Env, safeKey, data, cb) {
|
|
|
|
Channel.trimHistory = function (Env, safeKey, data, cb) {
|
|
|
|
if (!(data && typeof(data.channel) === 'string' && typeof(data.hash) === 'string' && data.hash.length === 64)) {
|
|
|
|
if (!(data && typeof(data.channel) === 'string' && typeof(data.hash) === 'string' && data.hash.length === 64)) {
|
|
|
|
return void cb('INVALID_ARGS');
|
|
|
|
return void cb('INVALID_ARGS');
|
|
|
|