sketch out trimHistory interface

This commit is contained in:
ansuz
2020-01-23 14:31:45 -05:00
parent 47290fca1e
commit 88dcadcb1b

26
rpc.js
View File

@@ -961,13 +961,27 @@ var removeOwnedChannel = function (Env, channelId, unsafeKey, cb) {
}; };
var removeOwnedChannelHistory = function (Env, channelId, unsafeKey, hash, cb) { var removeOwnedChannelHistory = function (Env, channelId, unsafeKey, hash, cb) {
// XXX validate that the user sending the request owns the channel in question nThen(function (w) {
// proceed to call Env.msgStore.trimChannel(channelId, hash, cb) if ok getMetadata(Env, channelId, w(function (err, metadata) {
// otherwise reject with INSUFFICIENT_PERMISSIONS if (err) { return void cb(err); }
if (!hasOwners(metadata)) {
w.abort();
return void cb('E_NO_OWNERS');
}
if (!isOwner(metadata, unsafeKey)) {
w.abort();
return void cb("INSUFFICIENT_PERMISSIONS");
}
// else fall through to the next block
}));
}).nThen(function () {
Env.msgStore.trimChannel(channelId, hash, function (err) {
if (err) { return void cb(err); }
// XXX if trimChannel calls back without an error
// you must also clear the channel's index from historyKeeper cache // XXX you must also clear the channel's index from historyKeeper cache
cb("E_NOT_IMPLEMENTED"); });
});
}; };
/* Users should be able to clear their own pin log with an authenticated RPC /* Users should be able to clear their own pin log with an authenticated RPC