|
|
@ -54,14 +54,29 @@ Channel.clearOwnedChannel = function (Env, safeKey, channelId, cb, Server) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var archiveOwnedChannel = function (Env, safeKey, channelId, cb, Server) {
|
|
|
|
var archiveOwnedChannel = function (Env, safeKey, channelId, _cb, Server) {
|
|
|
|
var unsafeKey = Util.unescapeKeyCharacters(safeKey);
|
|
|
|
var unsafeKey = Util.unescapeKeyCharacters(safeKey);
|
|
|
|
|
|
|
|
nThen(function (w) {
|
|
|
|
|
|
|
|
// confirm that the channel exists before worrying about whether
|
|
|
|
|
|
|
|
// we have permission to delete it.
|
|
|
|
|
|
|
|
var cb = _cb;
|
|
|
|
|
|
|
|
Env.msgStore.getChannelSize(channelId, w(function (err, bytes) {
|
|
|
|
|
|
|
|
if (!bytes) {
|
|
|
|
|
|
|
|
w.abort();
|
|
|
|
|
|
|
|
return cb(err || "ENOENT");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
}).nThen(function (w) {
|
|
|
|
|
|
|
|
var cb = Util.both(w.abort, _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'); }
|
|
|
|
if (!Core.isOwner(metadata, unsafeKey)) {
|
|
|
|
if (!Core.isOwner(metadata, unsafeKey)) {
|
|
|
|
return void cb('INSUFFICIENT_PERMISSIONS');
|
|
|
|
return void cb('INSUFFICIENT_PERMISSIONS');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}).nThen(function () {
|
|
|
|
|
|
|
|
var cb = _cb;
|
|
|
|
// temporarily archive the file
|
|
|
|
// temporarily archive the file
|
|
|
|
return void Env.msgStore.archiveChannel(channelId, function (e) {
|
|
|
|
return void Env.msgStore.archiveChannel(channelId, function (e) {
|
|
|
|
Env.Log.info('ARCHIVAL_CHANNEL_BY_OWNER_RPC', {
|
|
|
|
Env.Log.info('ARCHIVAL_CHANNEL_BY_OWNER_RPC', {
|
|
|
|