From 4a29d9df0032923010014b6582d2fd8407837eeb Mon Sep 17 00:00:00 2001 From: ansuz Date: Sun, 31 Jan 2021 15:28:45 +0530 Subject: [PATCH] implement admin GET_USER_TOTAL_SIZE call --- lib/commands/admin-rpc.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/commands/admin-rpc.js b/lib/commands/admin-rpc.js index 595b4c6dc..83e2ce8ca 100644 --- a/lib/commands/admin-rpc.js +++ b/lib/commands/admin-rpc.js @@ -5,6 +5,7 @@ const getFolderSize = require("get-folder-size"); const Util = require("../common-util"); const Ulimit = require("ulimit"); const Decrees = require("../decrees"); +const Pinning = require("./pin-rpc"); var Fs = require("fs"); @@ -324,6 +325,13 @@ var getLimits = function (Env, Server, cb) { cb(void 0, Env.limits); }; +// CryptPad_AsyncStore.rpc.send('ADMIN', ['GET_USER_TOTAL_SIZE', "CrufexqXcY/z+eKJlEbNELVy5Sb7E/EAAEFI8GnEtZ0="], console.log) +var getUserTotalSize = function (Env, Server, cb, data) { + var signingKey = Array.isArray(data) && data[1]; + if (typeof(signingKey) !== 'string' || signingKey.length < 44) { return void cb("EINVAL"); } // FIXME use a standard check for this + Pinning.getTotalSize(Env, signingKey, cb) +}; + var commands = { ACTIVE_SESSIONS: getActiveSessions, ACTIVE_PADS: getActiveChannelCount, @@ -349,6 +357,7 @@ var commands = { GET_LIMITS: getLimits, SET_LAST_EVICTION: setLastEviction, GET_WORKER_PROFILES: getWorkerProfiles, + GET_USER_TOTAL_SIZE: getUserTotalSize, }; Admin.command = function (Env, safeKey, data, _cb, Server) {