mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
core: blacklist tools
This commit is contained in:
1 parent
869c3131ca
commit
9b3ea0182b
5 files changed
+18
-37
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.23.10",
|
||||
"version": "2.23.11",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -16,26 +16,14 @@ function _validate(scheme: any, arg: any, base: string): void {
|
||||
}
|
||||
if (scheme.$group) _validate(scheme.$group, arg, base);
|
||||
if (scheme.$or) {
|
||||
if (scheme.$or instanceof Array) {
|
||||
for (const s of scheme.$or) {
|
||||
let success = false;
|
||||
try {
|
||||
_validate(s, arg, base);
|
||||
success = true;
|
||||
} catch { }
|
||||
// TODO beautify output
|
||||
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);
|
||||
}
|
||||
for (const s of scheme.$or) {
|
||||
let success = false;
|
||||
try {
|
||||
_validate(s, arg, base);
|
||||
success = true;
|
||||
} catch { }
|
||||
// TODO beautify output
|
||||
if (!success) throw new ValidationError(scheme.$or);
|
||||
}
|
||||
}
|
||||
if (scheme.$and) for (const s of scheme.$and) _validate(s, arg, base);
|
||||
|
||||
@@ -51,7 +51,7 @@ async function _user(
|
||||
if (!udoc) return;
|
||||
report({ message: `user ${udoc._id} ${udoc.uname}` });
|
||||
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();
|
||||
const tasks = [];
|
||||
for (const ddoc of ddocs) {
|
||||
@@ -76,12 +76,12 @@ export async function run({
|
||||
}
|
||||
|
||||
export const validate = {
|
||||
$or: {
|
||||
address: 'string',
|
||||
discuss: ObjectID,
|
||||
user: 'number',
|
||||
},
|
||||
dryrun: 'boolean',
|
||||
$or: [
|
||||
{ address: 'string' },
|
||||
{ discuss: ObjectID },
|
||||
{ user: 'number' },
|
||||
],
|
||||
dryrun: 'boolean?',
|
||||
};
|
||||
|
||||
global.Hydro.script.blacklist = { run, description, validate };
|
||||
@@ -106,7 +106,6 @@ export async function calcLevel(domainId: string, report: Function) {
|
||||
const levels = global.Hydro.model.builtin.LEVELS;
|
||||
bulk = coll.initializeUnorderedBulkOp();
|
||||
for (let i = 0; i < levels.length; i++) {
|
||||
report({ message: 'Updating users levelled {0}'.format(i) });
|
||||
const query: FilterQuery<Udoc> = {
|
||||
domainId,
|
||||
$and: [{ rank: { $lte: (levels[i] * count) / 100 } }],
|
||||
@@ -184,10 +183,7 @@ export async function run({ domainId }, report: Function) {
|
||||
}
|
||||
|
||||
export const validate = {
|
||||
$or: [
|
||||
{ domainId: 'string' },
|
||||
{ domainId: 'undefined' },
|
||||
],
|
||||
domainId: 'string?',
|
||||
};
|
||||
|
||||
global.Hydro.script.rp = { run, description, validate };
|
||||
@@ -24,10 +24,7 @@ export async function run({ domainId }, report: Function) {
|
||||
}
|
||||
|
||||
export const validate = {
|
||||
$or: [
|
||||
{ domainId: 'string' },
|
||||
{ domainId: 'undefined' },
|
||||
],
|
||||
domainId: 'string?',
|
||||
};
|
||||
|
||||
global.Hydro.script.updateFilelist = { run, description, validate };
|
||||
Reference in new issue
Block a user