sketch out trimHistory interface
This commit is contained in:
26
rpc.js
26
rpc.js
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user