From b4adf65dc8392fdb6049df9c58c554bdb6beaa05 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 20 Oct 2020 16:31:34 +0530 Subject: [PATCH 1/4] guard against a possible typeError in the worker --- www/common/outer/async-store.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index df05d8a3e..e849ce20d 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -256,7 +256,7 @@ define([ Store.getPinnedUsage = function (clientId, data, cb) { var s = getStore(data && data.teamId); - if (!s.rpc) { return void cb({error: 'RPC_NOT_READY'}); } + if (!s || !s.rpc) { return void cb({error: 'RPC_NOT_READY'}); } s.rpc.getFileListSize(function (err, bytes) { if (!s.id && typeof(bytes) === 'number') { From 488ec93ecebb02d78f22c004f3b3f73d46afdd33 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 20 Oct 2020 17:07:55 +0530 Subject: [PATCH 2/4] allow expert admins to get and clear cached channel indices --- lib/commands/admin-rpc.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/commands/admin-rpc.js b/lib/commands/admin-rpc.js index e67f75f6c..b7c5dfa52 100644 --- a/lib/commands/admin-rpc.js +++ b/lib/commands/admin-rpc.js @@ -175,6 +175,24 @@ var restoreArchivedDocument = function (Env, Server, cb) { cb("NOT_IMPLEMENTED"); }; +// CryptPad_AsyncStore.rpc.send('ADMIN', ['CLEAR_CHANNEL_INDEX', documentID], console.log) +var clearChannelIndex = function (Env, Server, cb, data) { + var id = Array.isArray(data) && data[1]; + if (typeof(id) !== 'string' || id.length < 32) { return void cb("EINVAL"); } + delete Env.channel_cache[id]; + cb(); +}; + +// CryptPad_AsyncStore.rpc.send('ADMIN', ['GET_CHANNEL_INDEX', documentID], console.log) +var getChannelIndex = function (Env, Server, cb, data) { + var id = Array.isArray(data) && data[1]; + if (typeof(id) !== 'string' || id.length < 32) { return void cb("EINVAL"); } + + var index = Util.find(Env, ['channel_cache', id]); + if (!index) { return void cb("ENOENT"); } + cb(void 0, index); +}; + // CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['RESTRICT_REGISTRATION', [true]]], console.log) var adminDecree = function (Env, Server, cb, data, unsafeKey) { var value = data[1]; @@ -269,6 +287,9 @@ var commands = { ARCHIVE_DOCUMENT: archiveDocument, RESTORE_ARCHIVED_DOCUMENT: restoreArchivedDocument, + CLEAR_CHANNEL_INDEX: clearChannelIndex, + GET_CHANNEL_INDEX: getChannelIndex, + ADMIN_DECREE: adminDecree, INSTANCE_STATUS: instanceStatus, GET_LIMITS: getLimits, From fbc9edd795328bb7f7a0dc99210b5aeac4dd13e1 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 20 Oct 2020 17:12:26 +0530 Subject: [PATCH 3/4] rename latest admin commands and implement metadata getter/remover --- lib/commands/admin-rpc.js | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/lib/commands/admin-rpc.js b/lib/commands/admin-rpc.js index b7c5dfa52..d7f22825d 100644 --- a/lib/commands/admin-rpc.js +++ b/lib/commands/admin-rpc.js @@ -175,7 +175,7 @@ var restoreArchivedDocument = function (Env, Server, cb) { cb("NOT_IMPLEMENTED"); }; -// CryptPad_AsyncStore.rpc.send('ADMIN', ['CLEAR_CHANNEL_INDEX', documentID], console.log) +// CryptPad_AsyncStore.rpc.send('ADMIN', ['CLEAR_CACHED_CHANNEL_INDEX', documentID], console.log) var clearChannelIndex = function (Env, Server, cb, data) { var id = Array.isArray(data) && data[1]; if (typeof(id) !== 'string' || id.length < 32) { return void cb("EINVAL"); } @@ -183,7 +183,7 @@ var clearChannelIndex = function (Env, Server, cb, data) { cb(); }; -// CryptPad_AsyncStore.rpc.send('ADMIN', ['GET_CHANNEL_INDEX', documentID], console.log) +// CryptPad_AsyncStore.rpc.send('ADMIN', ['GET_CACHED_CHANNEL_INDEX', documentID], console.log) var getChannelIndex = function (Env, Server, cb, data) { var id = Array.isArray(data) && data[1]; if (typeof(id) !== 'string' || id.length < 32) { return void cb("EINVAL"); } @@ -193,6 +193,24 @@ var getChannelIndex = function (Env, Server, cb, data) { cb(void 0, index); }; +// CryptPad_AsyncStore.rpc.send('ADMIN', ['CLEAR_CACHED_CHANNEL_METADATA', documentID], console.log) +var clearChannelMetadata = function (Env, Server, cb, data) { + var id = Array.isArray(data) && data[1]; + if (typeof(id) !== 'string' || id.length < 32) { return void cb("EINVAL"); } + delete Env.metadata_cache[id]; + cb(); +}; + +// CryptPad_AsyncStore.rpc.send('ADMIN', ['GET_CACHED_CHANNEL_METADATA', documentID], console.log) +var getChannelMetadata = function (Env, Server, cb, data) { + var id = Array.isArray(data) && data[1]; + if (typeof(id) !== 'string' || id.length < 32) { return void cb("EINVAL"); } + + var index = Util.find(Env, ['metadata_cache', id]); + if (!index) { return void cb("ENOENT"); } + cb(void 0, index); +}; + // CryptPad_AsyncStore.rpc.send('ADMIN', [ 'ADMIN_DECREE', ['RESTRICT_REGISTRATION', [true]]], console.log) var adminDecree = function (Env, Server, cb, data, unsafeKey) { var value = data[1]; @@ -287,8 +305,11 @@ var commands = { ARCHIVE_DOCUMENT: archiveDocument, RESTORE_ARCHIVED_DOCUMENT: restoreArchivedDocument, - CLEAR_CHANNEL_INDEX: clearChannelIndex, - GET_CHANNEL_INDEX: getChannelIndex, + CLEAR_CACHED_CHANNEL_INDEX: clearChannelIndex, + GET_CACHED_CHANNEL_INDEX: getChannelIndex, + + CLEAR_CACHED_CHANNEL_METADATA: clearChannelMetadata, + GET_CACHED_CHANNEL_METADATA: getChannelMetadata, ADMIN_DECREE: adminDecree, INSTANCE_STATUS: instanceStatus, From 19f3222da99abdb083442d0fb01f04f3a9e79cc9 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 20 Oct 2020 15:44:19 +0200 Subject: [PATCH 4/4] Exclude accounts app from the new pad menu --- www/common/common-ui-elements.js | 3 ++- www/common/drive-ui.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index f4630ae17..8b9415220 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -1239,8 +1239,8 @@ define([ } else if (!plan) { // user is logged in and subscriptions are allowed // and they don't have one. show upgrades - makeDonateButton(); makeUpgradeButton(); + makeDonateButton(); } else { // they have a plan. show nothing } @@ -1934,6 +1934,7 @@ define([ if (p === 'contacts') { return; } if (p === 'todo') { return; } if (p === 'file') { return; } + if (p === 'accounts') { return; } if (!common.isLoggedIn() && AppConfig.registeredOnlyTypes && AppConfig.registeredOnlyTypes.indexOf(p) !== -1) { return; } return true; diff --git a/www/common/drive-ui.js b/www/common/drive-ui.js index 6e2b29b7b..649b5fe86 100644 --- a/www/common/drive-ui.js +++ b/www/common/drive-ui.js @@ -2520,6 +2520,7 @@ define([ if (type === 'contacts') { return; } if (type === 'todo') { return; } if (type === 'file') { return; } + if (type === 'accounts') { return; } if (!APP.loggedIn && AppConfig.registeredOnlyTypes && AppConfig.registeredOnlyTypes.indexOf(type) !== -1) { return;