core&ui: allow copy/import as hidden

This commit is contained in:
undefined committed 2025-07-17 17:40:58 +08:00
1 parent 4165e9b153
commit aa2e35ab42
6 files changed
+46 -25

No files matched your search

+3 -1
View File
@@ -13,7 +13,8 @@ class ProblemImportHydroHandler extends Handler {
@param('keepUser', Types.Boolean)
@param('preferredPrefix', Types.String, true)
async post(domainId: string, keepUser: boolean, preferredPrefix?: string) {
@param('hidden', Types.Boolean)
async post(domainId: string, keepUser: boolean, preferredPrefix?: string, hidden?: boolean) {
if (keepUser) this.checkPriv(PRIV.PRIV_EDIT_SYSTEM);
if (!this.request.files.file) throw new ValidationError('file');
if (preferredPrefix && !/^[a-zA-Z]+$/.test(preferredPrefix)) throw new ValidationError('preferredPrefix');
@@ -24,6 +25,7 @@ class ProblemImportHydroHandler extends Handler {
progress: this.progress.bind(this),
operator: keepUser ? null : this.user._id,
delSource: true,
hidden,
},
).catch((e) => MessageModel.send(1, this.user._id, `Import failed: ${e.message}\n${e.stack}`));
let resolved = false;
+3 -2
View File
@@ -190,7 +190,8 @@ export class ProblemMainHandler extends Handler {
@param('pids', Types.NumericArray)
@param('target', Types.String)
async postCopy(domainId: string, pids: number[], target: string) {
@param('hidden', Types.Boolean)
async postCopy(domainId: string, pids: number[], target: string, hidden?: boolean) {
const t = `,${this.domain.share || ''},`;
if (t !== ',*,' && !t.includes(`,${target},`)) throw new PermissionError(target);
const ddoc = await domain.get(target);
@@ -205,7 +206,7 @@ export class ProblemMainHandler extends Handler {
const ids = [];
for (const pid of pids) {
// eslint-disable-next-line no-await-in-loop
ids.push(await problem.copy(domainId, pid, target));
ids.push(await problem.copy(domainId, pid, target, undefined, hidden));
}
this.response.body = ids;
}