From 7c072aeccb3f35c8280689f58397eb1d56dd60ab Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 20 Mar 2018 11:16:18 +0100 Subject: [PATCH] add remove-pins rpc --- rpc.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rpc.js b/rpc.js index 163d745cf..ae4971ae0 100644 --- a/rpc.js +++ b/rpc.js @@ -837,6 +837,17 @@ var removeOwnedChannel = function (Env, channelId, unsafeKey, cb) { }); }; +/* Users should be able to clear their own pin log with an authenticated RPC +*/ +var removePins = function (Env, safeKey, cb) { + if (typeof(Env.pinStore.removeChannel) !== 'function') { + return void cb("E_NOT_IMPLEMENTED"); + } + Env.pinStore.removeChannel(safeKey, function (err) { + cb(err); + }); +}; + var upload = function (Env, publicKey, content, cb) { var paths = Env.paths; var dec; @@ -1153,6 +1164,7 @@ var isAuthenticatedCall = function (call) { 'EXPIRE_SESSION', 'CLEAR_OWNED_CHANNEL', 'REMOVE_OWNED_CHANNEL', + 'REMOVE_PINS', ].indexOf(call) !== -1; }; @@ -1445,6 +1457,11 @@ RPC.create = function ( if (e) { return void Respond(e); } Respond(void 0, "OK"); }); + case 'REMOVE_PINS': + return void removePins(Env, safeKey, function (e, response) { + if (e) { return void Respond(e); } + Respond(void 0, response); + }); // restricted to privileged users... case 'UPLOAD': if (!privileged) { return deny(); }