Merge branch 'justification' into mar7

pull/1/head
ansuz 3 years ago
commit 8398c05f1a

@ -155,7 +155,17 @@ var flushCache = function (Env, Server, cb) {
// CryptPad_AsyncStore.rpc.send('ADMIN', ['ARCHIVE_DOCUMENT', documentID], console.log) // CryptPad_AsyncStore.rpc.send('ADMIN', ['ARCHIVE_DOCUMENT', documentID], console.log)
var archiveDocument = function (Env, Server, cb, data) { var archiveDocument = function (Env, Server, cb, data) {
var id = Array.isArray(data) && data[1]; if (!Array.isArray(data)) { return void cb("EINVAL"); }
var args = data[1];
var id, reason;
if (typeof(args) === 'string') {
id = args;
} else if (args && typeof(args) === 'object') {
id = args.id;
reason = args.reason;
}
if (typeof(id) !== 'string' || id.length < 32) { return void cb("EINVAL"); } if (typeof(id) !== 'string' || id.length < 32) { return void cb("EINVAL"); }
switch (id.length) { switch (id.length) {
@ -164,6 +174,7 @@ var archiveDocument = function (Env, Server, cb, data) {
return void Env.msgStore.archiveChannel(id, Util.both(cb, function (err) { return void Env.msgStore.archiveChannel(id, Util.both(cb, function (err) {
Env.Log.info("ARCHIVAL_CHANNEL_BY_ADMIN_RPC", { Env.Log.info("ARCHIVAL_CHANNEL_BY_ADMIN_RPC", {
channelId: id, channelId: id,
reason: reason,
status: err? String(err): "SUCCESS", status: err? String(err): "SUCCESS",
}); });
})); }));
@ -171,6 +182,7 @@ var archiveDocument = function (Env, Server, cb, data) {
return void Env.blobStore.archive.blob(id, Util.both(cb, function (err) { return void Env.blobStore.archive.blob(id, Util.both(cb, function (err) {
Env.Log.info("ARCHIVAL_BLOB_BY_ADMIN_RPC", { Env.Log.info("ARCHIVAL_BLOB_BY_ADMIN_RPC", {
id: id, id: id,
reason: reason,
status: err? String(err): "SUCCESS", status: err? String(err): "SUCCESS",
}); });
})); }));
@ -184,7 +196,17 @@ var archiveDocument = function (Env, Server, cb, data) {
}; };
var restoreArchivedDocument = function (Env, Server, cb, data) { var restoreArchivedDocument = function (Env, Server, cb, data) {
var id = Array.isArray(data) && data[1]; if (!Array.isArray(data)) { return void cb("EINVAL"); }
var args = data[1];
var id, reason;
if (typeof(args) === 'string') {
id = args;
} else if (args && typeof(args) === 'object') {
id = args.id;
reason = args.reason;
}
if (typeof(id) !== 'string' || id.length < 32) { return void cb("EINVAL"); } if (typeof(id) !== 'string' || id.length < 32) { return void cb("EINVAL"); }
switch (id.length) { switch (id.length) {
@ -192,6 +214,7 @@ var restoreArchivedDocument = function (Env, Server, cb, data) {
return void Env.msgStore.restoreArchivedChannel(id, Util.both(cb, function (err) { return void Env.msgStore.restoreArchivedChannel(id, Util.both(cb, function (err) {
Env.Log.info("RESTORATION_CHANNEL_BY_ADMIN_RPC", { Env.Log.info("RESTORATION_CHANNEL_BY_ADMIN_RPC", {
id: id, id: id,
reason: reason,
status: err? String(err): 'SUCCESS', status: err? String(err): 'SUCCESS',
}); });
})); }));
@ -201,6 +224,7 @@ var restoreArchivedDocument = function (Env, Server, cb, data) {
return void Env.blobStore.restore.blob(id, Util.both(cb, function (err) { return void Env.blobStore.restore.blob(id, Util.both(cb, function (err) {
Env.Log.info("RESTORATION_BLOB_BY_ADMIN_RPC", { Env.Log.info("RESTORATION_BLOB_BY_ADMIN_RPC", {
id: id, id: id,
reason: reason,
status: err? String(err): 'SUCCESS', status: err? String(err): 'SUCCESS',
}); });
})); }));

@ -149,6 +149,8 @@ define([
return $div; return $div;
}; };
Messages.admin_archiveReason = "// XXX REASON"; // XXX
var archiveForm = function (archive, $div, $button) { var archiveForm = function (archive, $div, $button) {
var label = h('label', { for: 'cp-admin-archive' }, Messages.admin_archiveInput); var label = h('label', { for: 'cp-admin-archive' }, Messages.admin_archiveInput);
var input = h('input#cp-admin-archive', { var input = h('input#cp-admin-archive', {
@ -162,6 +164,14 @@ define([
id: 'cp-admin-archive-pw', id: 'cp-admin-archive-pw',
placeholder: Messages.login_password placeholder: Messages.login_password
}); });
var input3 = h('input', {
id: 'cp-admin-archive-reason',
placeholder: Messages.admin_archiveReason,
});
var label3 = h('label', {
for: 'cp-admin-archive-reason',
}, Messages.admin_archiveReason);
var $pw = $(input2); var $pw = $(input2);
$pw.addClass('cp-admin-pw'); $pw.addClass('cp-admin-pw');
var $pwInput = $pw.find('input'); var $pwInput = $pw.find('input');
@ -171,7 +181,9 @@ define([
label, label,
input, input,
label2, label2,
input2 input2,
label3,
input3,
])); ]));
$div.addClass('cp-admin-nopassword'); $div.addClass('cp-admin-nopassword');
@ -237,9 +249,13 @@ define([
} }
}), true); }), true);
}).nThen(function () { }).nThen(function () {
var $reason = $(input3);
sFrameChan.query('Q_ADMIN_RPC', { sFrameChan.query('Q_ADMIN_RPC', {
cmd: archive ? 'ARCHIVE_DOCUMENT' : 'RESTORE_ARCHIVED_DOCUMENT', cmd: archive ? 'ARCHIVE_DOCUMENT' : 'RESTORE_ARCHIVED_DOCUMENT',
data: channel data: {
id: channel,
reason: $reason.val(), // XXX
},
}, function (err, obj) { }, function (err, obj) {
var e = err || (obj && obj.error); var e = err || (obj && obj.error);
clicked = false; clicked = false;
@ -251,6 +267,7 @@ define([
UI.log(archive ? Messages.archivedFromServer : Messages.restoredFromServer); UI.log(archive ? Messages.archivedFromServer : Messages.restoredFromServer);
$input.val(''); $input.val('');
$pwInput.val(''); $pwInput.val('');
$reason.val('')
}); });
}); });
}); });

Loading…
Cancel
Save