From 9c28941f6c7a233b09ee2e35b67acb68f353b58f Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 5 Feb 2020 10:47:43 -0500 Subject: [PATCH 1/2] lint compliance --- lib/commands/core.js | 2 +- lib/rpc.js | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/commands/core.js b/lib/commands/core.js index 3e98d10dd..cbcf291bb 100644 --- a/lib/commands/core.js +++ b/lib/commands/core.js @@ -70,7 +70,7 @@ Core.expireSession = function (Sessions, safeKey) { Core.expireSessionAsync = function (Env, safeKey, cb) { setTimeout(function () { - Core.expireSession(Sessions, safeKey); + Core.expireSession(Env.Sessions, safeKey); cb(void 0, 'OK'); }); }; diff --git a/lib/rpc.js b/lib/rpc.js index d541a2550..7e46303e4 100644 --- a/lib/rpc.js +++ b/lib/rpc.js @@ -196,8 +196,6 @@ var handleAuthenticatedMessage = function (Env, map) { Respond(void 0, result); }); default: - console.log(msg); - throw new Error("OOPS"); return void Respond('UNSUPPORTED_RPC_CALL', msg); } }; From 5808c534b5c8906904eb60f7557bda5c49afcbb0 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 5 Feb 2020 11:53:47 -0500 Subject: [PATCH 2/2] fix function signature for trimHistory RPC --- lib/commands/channel.js | 10 +++++++++- lib/rpc.js | 6 +----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/commands/channel.js b/lib/commands/channel.js index f50894016..318911bd8 100644 --- a/lib/commands/channel.js +++ b/lib/commands/channel.js @@ -93,7 +93,15 @@ Channel.removeOwnedChannel = function (Env, safeKey, channelId, cb) { }); }; -Channel.removeOwnedChannelHistory = function (Env, channelId, unsafeKey, hash, cb) { // XXX UNSAFE +Channel.trimHistory = function (Env, safeKey, data, cb) { + if (!(data && typeof(data.channel) === 'string' && typeof(data.hash) === 'string' && data.hash.length === 64)) { + return void cb('INVALID_ARGS'); + } + + var channelId = data.channel; + var unsafeKey = Util.unescapeKeyCharacters(safeKey); + var hash = data.hash; + nThen(function (w) { Metadata.getMetadata(Env, channelId, w(function (err, metadata) { if (err) { return void cb(err); } diff --git a/lib/rpc.js b/lib/rpc.js index 7e46303e4..11a9bb06f 100644 --- a/lib/rpc.js +++ b/lib/rpc.js @@ -118,6 +118,7 @@ const AUTHENTICATED_USER_TARGETED = { UNPIN: Pinning.unpinChannel, CLEAR_OWNED_CHANNEL: Channel.clearOwnedChannel, REMOVE_OWNED_CHANNEL: Channel.removeOwnedChannel, + TRIM_HISTORY: Channel.trimHistory, UPLOAD_STATUS: Upload.status, UPLOAD: Upload.upload, UPLOAD_COMPLETE: Upload.complete, @@ -166,11 +167,6 @@ var handleAuthenticatedMessage = function (Env, map) { switch (msg[0]) { case 'COOKIE': return void Respond(void 0); - case 'TRIM_OWNED_CHANNEL_HISTORY': - return void Channel.removeOwnedChannelHistory(Env, msg[1], publicKey, msg[2], function (e) { // XXX USER_TARGETED_DOUBLE - if (e) { return void Respond(e); } - Respond(void 0, 'OK'); - }); case 'WRITE_LOGIN_BLOCK': return void Block.writeLoginBlock(Env, msg[1], function (e) { // XXX SPECIAL if (e) {