mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: 忽略域id中大小写差异
This commit is contained in:
1 parent
bff392e73f
commit
b13b8835ec
3 files changed
+9
-2
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.28.55",
|
||||
"version": "2.28.56",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -45,6 +45,7 @@ class DomainModel {
|
||||
static async add(domainId: string, owner: number, name: string, bulletin: string) {
|
||||
const ddoc: DomainDoc = {
|
||||
_id: domainId,
|
||||
lower: domainId.toLowerCase(),
|
||||
owner,
|
||||
name,
|
||||
bulletin,
|
||||
@@ -59,7 +60,7 @@ class DomainModel {
|
||||
|
||||
@ArgMethod
|
||||
static async get(domainId: string): Promise<DomainDoc | null> {
|
||||
const query: FilterQuery<DomainDoc> = { _id: domainId };
|
||||
const query: FilterQuery<DomainDoc> = { lower: domainId.toLowerCase() };
|
||||
await bus.serial('domain/before-get', query);
|
||||
const result = await coll.findOne(query);
|
||||
await bus.serial('domain/get', result);
|
||||
@@ -274,5 +275,6 @@ class DomainModel {
|
||||
}
|
||||
}
|
||||
|
||||
bus.on('app/started', () => coll.createIndex({ lower: 1 }, { unique: true }));
|
||||
export default DomainModel;
|
||||
global.Hydro.model.domain = DomainModel;
|
||||
@@ -423,6 +423,11 @@ const scripts: UpgradeScript[] = [
|
||||
});
|
||||
return true;
|
||||
},
|
||||
async function _34_35() {
|
||||
const _FRESH_INSTALL_IGNORE = 1;
|
||||
await iterateAllDomain((ddoc) => domain.edit(ddoc._id, { lower: ddoc._id.toLowerCase() }));
|
||||
return true;
|
||||
},
|
||||
];
|
||||
|
||||
export default scripts;
|
||||
Reference in new issue
Block a user