mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: remove deprecated apis
This commit is contained in:
1 parent
05b27fc1eb
commit
ec0ba8a394
9 files changed
+24
-37
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { exec } from 'child_process';
|
||||
import { inspect } from 'util';
|
||||
import * as yaml from 'js-yaml';
|
||||
import { omit } from 'lodash';
|
||||
import Schema from 'schemastery';
|
||||
import * as check from '../check';
|
||||
import {
|
||||
@@ -276,9 +277,7 @@ class SystemUserImportHandler extends SystemHandler {
|
||||
}
|
||||
/* eslint-enable no-await-in-loop */
|
||||
|
||||
const Priv = Object.fromEntries(Object.entries(PRIV).filter(
|
||||
(i) => (!i[0].endsWith('SELF') && !['PRIV_DEFAULT', 'PRIV_NEVER', 'PRIV_NONE', 'PRIV_ALL'].includes(i[0])),
|
||||
));
|
||||
const Priv = omit(PRIV, ['PRIV_DEFAULT', 'PRIV_NEVER', 'PRIV_NONE', 'PRIV_ALL']);
|
||||
const allPriv = Math.sum(Object.values(Priv));
|
||||
|
||||
class SystemUserPrivHandler extends SystemHandler {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const versionNum = +process.version.replace(/v/gim, '').split('.')[0];
|
||||
if (versionNum < 14) throw new Error('NodeJS >=14 required');
|
||||
if (versionNum < 18) throw new Error('NodeJS >=18 required');
|
||||
|
||||
console.log('Process', process.pid, 'running as', process.env.NODE_APP_INSTANCE === '0' ? 'master' : 'worker');
|
||||
if (!global.Hydro) {
|
||||
|
||||
@@ -727,7 +727,6 @@ export type ProblemSearch = (domainId: string, q: string, options?: ProblemSearc
|
||||
export interface Lib extends Record<string, any> {
|
||||
difficulty: typeof import('./lib/difficulty');
|
||||
buildContent: typeof import('./lib/content').buildContent;
|
||||
i18n: typeof import('./lib/i18n');
|
||||
mail: typeof import('./lib/mail');
|
||||
paginate: typeof import('./lib/paginate');
|
||||
rank: typeof import('./lib/rank');
|
||||
|
||||
@@ -52,13 +52,6 @@ String.prototype.translate = function translate(...languages: string[]) {
|
||||
return this.toString();
|
||||
};
|
||||
|
||||
/** @deprecated use ctx.i18n.load instead. */
|
||||
function load(data: Record<string, Record<string, string>>) {
|
||||
for (const i in data) app.i18n.load(i, data[i]);
|
||||
}
|
||||
|
||||
export = load;
|
||||
|
||||
function collect(lang: string) {
|
||||
const s = translations[lang];
|
||||
if (!(s instanceof Array)) return {};
|
||||
@@ -81,4 +74,3 @@ global.Hydro.locales = new Proxy(translations, {
|
||||
});
|
||||
},
|
||||
}) as any;
|
||||
global.Hydro.lib.i18n = load;
|
||||
@@ -11,6 +11,7 @@ import path from 'path';
|
||||
import './utils';
|
||||
import cac from 'cac';
|
||||
import './ui';
|
||||
import './lib/i18n';
|
||||
|
||||
import { Logger } from './logger';
|
||||
import { Context } from './context';
|
||||
|
||||
@@ -256,19 +256,10 @@ export const PRIV = {
|
||||
PRIV_ALL: -1,
|
||||
PRIV_DEFAULT: 0,
|
||||
PRIV_NEVER: 1 << 20,
|
||||
|
||||
/** @deprecated */
|
||||
PRIV_READ_PRETEST_DATA: 1 << 5,
|
||||
/** @deprecated */
|
||||
PRIV_READ_PRETEST_DATA_SELF: 1 << 6,
|
||||
/** @deprecated */
|
||||
PRIV_DELETE_FILE_SELF: 1 << 19,
|
||||
};
|
||||
|
||||
PRIV.PRIV_DEFAULT = PRIV.PRIV_USER_PROFILE
|
||||
+ PRIV.PRIV_READ_PRETEST_DATA_SELF
|
||||
+ PRIV.PRIV_CREATE_FILE
|
||||
+ PRIV.PRIV_DELETE_FILE_SELF
|
||||
+ PRIV.PRIV_SEND_MESSAGE;
|
||||
|
||||
// people whose rank is less than 1% will get Level 10
|
||||
|
||||
@@ -277,12 +277,6 @@ class DomainModel {
|
||||
await bus.parallel('domain/delete', domainId);
|
||||
bus.broadcast('domain/delete-cache', domainId.toLowerCase());
|
||||
}
|
||||
|
||||
@ArgMethod
|
||||
/** @deprecated */
|
||||
static async getUnion(domainId: string) {
|
||||
return await coll.findOne({ _id: domainId });
|
||||
}
|
||||
}
|
||||
|
||||
bus.on('ready', () => Promise.all([
|
||||
|
||||
@@ -187,11 +187,6 @@ class RemoteStorageService {
|
||||
}));
|
||||
}
|
||||
|
||||
/** @deprecated use StorageModel.list instead. */
|
||||
async list() {
|
||||
throw new Error('listObjectsAPI was no longer supported in hydrooj@4. Please use hydrooj@3 to migrate your files first.');
|
||||
}
|
||||
|
||||
async getMeta(target: string) {
|
||||
target = convertPath(target);
|
||||
const res = await this.client.send(new HeadObjectCommand({
|
||||
@@ -320,10 +315,6 @@ class LocalStorageService {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
|
||||
async list() {
|
||||
throw new Error('deprecated');
|
||||
}
|
||||
|
||||
async copy(src: string, target: string) {
|
||||
src = resolve(this.dir, convertPath(src));
|
||||
target = resolve(this.dir, convertPath(target));
|
||||
|
||||
@@ -513,6 +513,26 @@ const scripts: UpgradeScript[] = [
|
||||
await ScheduleModel.deleteMany({ subType: 'discussion.sort' });
|
||||
return true;
|
||||
},
|
||||
async function _74_75() {
|
||||
const list = {
|
||||
READ_PRETEST_DATA: 1 << 5,
|
||||
READ_PRETEST_DATA_SELF: 1 << 6,
|
||||
DELETE_FILE_SELF: 1 << 19,
|
||||
};
|
||||
let defaultPriv = system.get('default.priv') as number;
|
||||
for (const key in list) {
|
||||
if (defaultPriv & list[key]) defaultPriv -= list[key];
|
||||
}
|
||||
await system.set('default.priv', defaultPriv);
|
||||
return iterateAllUser(async (udoc) => {
|
||||
if (udoc.priv < 0) return;
|
||||
const old = udoc.priv;
|
||||
for (const key in list) {
|
||||
if (udoc.priv & list[key]) udoc.priv -= list[key];
|
||||
}
|
||||
if (old !== udoc.priv) await user.setById(udoc._id, udoc);
|
||||
});
|
||||
},
|
||||
];
|
||||
|
||||
export default scripts;
|
||||
Reference in new issue
Block a user