core: blacklist tools

This commit is contained in:
undefined committed 2021-04-21 13:07:42 +08:00
1 parent 869c3131ca
commit 9b3ea0182b
5 files changed
+10 -29

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.23.10", "version": "2.23.11",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "dist/loader.js", "main": "dist/loader.js",
"typings": "dist/loader.d.ts", "typings": "dist/loader.d.ts",
-12
View File
@@ -16,7 +16,6 @@ function _validate(scheme: any, arg: any, base: string): void {
} }
if (scheme.$group) _validate(scheme.$group, arg, base); if (scheme.$group) _validate(scheme.$group, arg, base);
if (scheme.$or) { if (scheme.$or) {
if (scheme.$or instanceof Array) {
for (const s of scheme.$or) { for (const s of scheme.$or) {
let success = false; let success = false;
try { try {
@@ -26,17 +25,6 @@ function _validate(scheme: any, arg: any, base: string): void {
// TODO beautify output // TODO beautify output
if (!success) throw new ValidationError(scheme.$or); if (!success) throw new ValidationError(scheme.$or);
} }
} else {
for (const skey in scheme.$or) {
let success = false;
try {
_validate(scheme.$or[skey], arg[skey], `${base}.${skey}`);
success = true;
} catch { }
// TODO beautify output
if (!success) throw new ValidationError(base, scheme.$or);
}
}
} }
if (scheme.$and) for (const s of scheme.$and) _validate(s, arg, base); if (scheme.$and) for (const s of scheme.$and) _validate(s, arg, base);
if (scheme.$type) { if (scheme.$type) {
+7 -7
View File
@@ -51,7 +51,7 @@ async function _user(
if (!udoc) return; if (!udoc) return;
report({ message: `user ${udoc._id} ${udoc.uname}` }); report({ message: `user ${udoc._id} ${udoc.uname}` });
await _address(udoc.loginip(), bset, uset, dset, dryrun, report); await _address(udoc.loginip(), bset, uset, dset, dryrun, report);
const ddocs = await db.collection('document').find({ docType: document.TYPE_DISCUSSION }) const ddocs = await db.collection('document').find({ docType: document.TYPE_DISCUSSION, owner: uid })
.sort({ domainId: 1, docId: 1 }).toArray(); .sort({ domainId: 1, docId: 1 }).toArray();
const tasks = []; const tasks = [];
for (const ddoc of ddocs) { for (const ddoc of ddocs) {
@@ -76,12 +76,12 @@ export async function run({
} }
export const validate = { export const validate = {
$or: { $or: [
address: 'string', { address: 'string' },
discuss: ObjectID, { discuss: ObjectID },
user: 'number', { user: 'number' },
}, ],
dryrun: 'boolean', dryrun: 'boolean?',
}; };
global.Hydro.script.blacklist = { run, description, validate }; global.Hydro.script.blacklist = { run, description, validate };
+1 -5
View File
@@ -106,7 +106,6 @@ export async function calcLevel(domainId: string, report: Function) {
const levels = global.Hydro.model.builtin.LEVELS; const levels = global.Hydro.model.builtin.LEVELS;
bulk = coll.initializeUnorderedBulkOp(); bulk = coll.initializeUnorderedBulkOp();
for (let i = 0; i < levels.length; i++) { for (let i = 0; i < levels.length; i++) {
report({ message: 'Updating users levelled {0}'.format(i) });
const query: FilterQuery<Udoc> = { const query: FilterQuery<Udoc> = {
domainId, domainId,
$and: [{ rank: { $lte: (levels[i] * count) / 100 } }], $and: [{ rank: { $lte: (levels[i] * count) / 100 } }],
@@ -184,10 +183,7 @@ export async function run({ domainId }, report: Function) {
} }
export const validate = { export const validate = {
$or: [ domainId: 'string?',
{ domainId: 'string' },
{ domainId: 'undefined' },
],
}; };
global.Hydro.script.rp = { run, description, validate }; global.Hydro.script.rp = { run, description, validate };
@@ -24,10 +24,7 @@ export async function run({ domainId }, report: Function) {
} }
export const validate = { export const validate = {
$or: [ domainId: 'string?',
{ domainId: 'string' },
{ domainId: 'undefined' },
],
}; };
global.Hydro.script.updateFilelist = { run, description, validate }; global.Hydro.script.updateFilelist = { run, description, validate };