Skip to content

Commit be72cac

Browse files
committed
core: fix discussion history
1 parent 273ff95 commit be72cac

3 files changed

Lines changed: 10 additions & 11 deletions

File tree

packages/hydrooj/src/handler/discussion.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,15 +368,8 @@ class DiscussionRawHandler extends DiscussionHandler {
368368

369369
class DiscussionEditHandler extends DiscussionHandler {
370370
async get() {
371-
const path = [
372-
['Hydro', 'homepage'],
373-
['discussion_main', 'discussion_main'],
374-
[this.vnode.title, 'discussion_node', { type: discussion.typeDisplay[this.ddoc.parentType], name: this.ddoc.parentId }, true],
375-
[this.ddoc.title, 'discussion_detail', { did: this.ddoc.docId }, true],
376-
['discussion_edit', null],
377-
];
378371
this.response.template = 'discussion_edit.html';
379-
this.response.body = { ddoc: this.ddoc, path };
372+
this.response.body = { ddoc: this.ddoc };
380373
}
381374

382375
@param('did', Types.ObjectId)

packages/hydrooj/src/model/discussion.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,11 @@ export async function get<T extends Field>(
8484
}
8585

8686
export async function edit(domainId: string, did: ObjectId, $set: Partial<DiscussionDoc>) {
87-
await coll.insertOne({
88-
domainId, docId: did, content: $set.content, uid: $set.editor, ip: $set.ip, time: new Date(),
89-
});
87+
if ($set.content) {
88+
await coll.insertOne({
89+
domainId, docId: did, content: $set.content, uid: $set.editor, ip: $set.ip, time: new Date(),
90+
});
91+
}
9092
return document.set(domainId, document.TYPE_DISCUSSION, did, $set);
9193
}
9294

packages/hydrooj/src/upgrade.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,4 +615,8 @@ export const coreScripts: MigrationScript[] = [
615615
});
616616
return true;
617617
},
618+
async function _94_95() {
619+
await discussion.coll.deleteMany({ content: { $not: { $type: 'string' } } });
620+
return true;
621+
},
618622
];

0 commit comments

Comments
 (0)