core: problem discussion index

This commit is contained in:
undefined committed 2021-08-05 17:53:11 +08:00
1 parent 4dd428ba35
commit 189021d41a
3 files changed
+15 -9

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.30.13",
"version": "2.30.14",
"bin": "bin/hydrooj.js",
"main": "src/loader",
"module": "src/loader",
+3 -8
View File
@@ -147,24 +147,19 @@ class DiscussionCreateHandler extends DiscussionHandler {
}
@param('type', Types.Name)
@param('name', Types.Name)
@param('title', Types.Title)
@param('content', Types.Content)
@param('highlight', Types.Boolean)
@param('pin', Types.Boolean)
async post(
domainId: string, type: string, _name: string,
title: string, content: string, highlight = false, pin = false,
domainId: string, type: string, title: string,
content: string, highlight = false, pin = false,
) {
await this.limitRate('add_discussion', 3600, 60);
let name: ObjectID | string | number;
if (ObjectID.isValid(_name)) name = new ObjectID(_name);
else if (isSafeInteger(+name)) name = +name;
else name = _name;
if (highlight) this.checkPerm(PERM.PERM_HIGHLIGHT_DISCUSSION);
if (pin) this.checkPerm(PERM.PERM_PIN_DISCUSSION);
const did = await discussion.add(
domainId, typeMapper[type], name, this.user._id,
domainId, typeMapper[type], this.vnode.docId, this.user._id,
title, content, this.request.ip, highlight, pin,
);
this.response.body = { did };
+11
View File
@@ -435,6 +435,17 @@ const scripts: UpgradeScript[] = [
});
return true;
},
async function _39_40() {
const _FRESH_INSTALL_IGNORE = 1;
await iterateAllDomain(async ({ _id }) => {
const ddocs = await discussion.getMulti(_id, { parentType: document.TYPE_PROBLEM }).toArray();
for (const ddoc of ddocs) {
const pdoc = await problem.get(_id, ddoc.parentId as any);
await document.set(_id, document.TYPE_DISCUSSION, ddoc.docId, { parentId: pdoc.docId });
}
});
return true;
},
];
export default scripts;