|
|
@ -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',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|