mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
记录discussion删除事件
This commit is contained in:
1 parent
7ceb8fc028
commit
daa5bffd8c
6 files changed
+31
-4
No files matched your search
+1
-1
@@ -52,9 +52,9 @@ const configFlat = {
|
||||
const packages = fs.readdirSync(path.resolve(process.cwd(), 'packages'));
|
||||
console.log(packages);
|
||||
for (const package of packages) {
|
||||
if (package !== 'hydrooj') config.references.push({ path: `packages/${package}` });
|
||||
const files = fs.readdirSync(path.resolve(process.cwd(), 'packages', package));
|
||||
if (!files.includes('src') && !files.map(n => n.split('.')[1]).includes('ts')) continue;
|
||||
if (package !== 'hydrooj') config.references.push({ path: `packages/${package}` });
|
||||
fs.writeFileSync(
|
||||
path.resolve(process.cwd(), 'packages', package, 'tsconfig.json'),
|
||||
files.includes('src') ? JSON.stringify(configSrc) : JSON.stringify(configFlat),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.13.23",
|
||||
"version": "2.13.24",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -18,7 +18,7 @@ export const builtinModel = [
|
||||
'builtin', 'document', 'domain', 'blacklist', 'opcount',
|
||||
'setting', 'token', 'user', 'problem', 'record',
|
||||
'contest', 'message', 'solution', 'training', 'file',
|
||||
'discussion', 'system',
|
||||
'discussion', 'system', 'oplog',
|
||||
];
|
||||
|
||||
export const builtinHandler = [
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
} from '../interface';
|
||||
import paginate from '../lib/paginate';
|
||||
import * as user from '../model/user';
|
||||
import * as oplog from '../model/oplog';
|
||||
import * as message from '../model/message';
|
||||
import * as discussion from '../model/discussion';
|
||||
import * as document from '../model/document';
|
||||
@@ -257,6 +258,7 @@ class DiscussionDetailHandler extends DiscussionHandler {
|
||||
} else this.checkPerm(PERM.PERM_DELETE_DISCUSSION_SELF);
|
||||
}
|
||||
await discussion.delReply(domainId, drid);
|
||||
await oplog.add({ ...this.drdoc, operator: this.user._id, type: 'drdoc' });
|
||||
this.back();
|
||||
}
|
||||
|
||||
@@ -275,6 +277,7 @@ class DiscussionDetailHandler extends DiscussionHandler {
|
||||
async postDeleteTailReply(domainId: string, drid: ObjectID, drrid: ObjectID) {
|
||||
if (this.drrdoc.owner !== this.user._id) this.checkPerm(PERM.PERM_DELETE_DISCUSSION_REPLY);
|
||||
await discussion.delTailReply(domainId, drid, drrid);
|
||||
await oplog.add({ ...this.drrdoc, operator: this.user._id, type: 'drrdoc' });
|
||||
this.back();
|
||||
}
|
||||
|
||||
@@ -348,6 +351,7 @@ class DiscussionEditHandler extends DiscussionHandler {
|
||||
if (this.ddoc.owner !== this.user._id) this.checkPerm(PERM.PERM_DELETE_DISCUSSION);
|
||||
else this.checkPerm(PERM.PERM_DELETE_DISCUSSION_SELF);
|
||||
await discussion.del(domainId, did);
|
||||
await oplog.add({ ...this.ddoc, operator: this.user._id, type: 'ddoc' });
|
||||
this.response.body = { type: this.ddoc.parentType, parent: this.ddoc.parentId };
|
||||
this.response.redirect = this.url('discussion_node', {
|
||||
type: discussion.typeDisplay[this.ddoc.parentType],
|
||||
|
||||
@@ -374,7 +374,12 @@ export interface TokenDoc {
|
||||
[key: string]: any,
|
||||
}
|
||||
|
||||
export interface ContestStat extends Dictionary<any> {
|
||||
export interface OplogDoc extends Record<string, any> {
|
||||
_id: ObjectID,
|
||||
type: string,
|
||||
}
|
||||
|
||||
export interface ContestStat extends Record<string, any> {
|
||||
detail: any,
|
||||
}
|
||||
|
||||
@@ -464,6 +469,7 @@ export interface Collections {
|
||||
'oauth': any,
|
||||
'system': System,
|
||||
'task': Task,
|
||||
'oplog': OplogDoc,
|
||||
'opcount': any,
|
||||
'fs.chunks': any,
|
||||
'fs.files': any,
|
||||
@@ -486,6 +492,7 @@ export interface Model {
|
||||
solution: typeof import('./model/solution'),
|
||||
system: typeof import('./model/system'),
|
||||
task: typeof import('./model/task'),
|
||||
oplog: typeof import('./model/oplog'),
|
||||
token: typeof import('./model/token'),
|
||||
training: typeof import('./model/training'),
|
||||
user: typeof import('./model/user'),
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { ObjectID } from 'mongodb';
|
||||
import { OplogDoc } from '../interface';
|
||||
import * as db from '../service/db';
|
||||
|
||||
export const coll = db.collection('oplog');
|
||||
|
||||
export async function add(data: Partial<OplogDoc>): Promise<ObjectID> {
|
||||
const res = await coll.insertOne(data);
|
||||
return res.insertedId;
|
||||
}
|
||||
|
||||
export async function get(id: ObjectID): Promise<OplogDoc | null> {
|
||||
return await coll.findOne({ _id: id });
|
||||
}
|
||||
|
||||
global.Hydro.model.oplog = { coll, add, get };
|
||||
Reference in new issue
Block a user