From be72cac27f52be9ea1c3f37c1f091ea167c5b7f8 Mon Sep 17 00:00:00 2001 From: undefined Date: Wed, 25 Jun 2025 04:08:33 +0800 Subject: [PATCH] core: fix discussion history --- packages/hydrooj/src/handler/discussion.ts | 9 +-------- packages/hydrooj/src/model/discussion.ts | 8 +++++--- packages/hydrooj/src/upgrade.ts | 4 ++++ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/hydrooj/src/handler/discussion.ts b/packages/hydrooj/src/handler/discussion.ts index fbed8ad50..75baaf9ec 100644 --- a/packages/hydrooj/src/handler/discussion.ts +++ b/packages/hydrooj/src/handler/discussion.ts @@ -368,15 +368,8 @@ class DiscussionRawHandler extends DiscussionHandler { class DiscussionEditHandler extends DiscussionHandler { async get() { - const path = [ - ['Hydro', 'homepage'], - ['discussion_main', 'discussion_main'], - [this.vnode.title, 'discussion_node', { type: discussion.typeDisplay[this.ddoc.parentType], name: this.ddoc.parentId }, true], - [this.ddoc.title, 'discussion_detail', { did: this.ddoc.docId }, true], - ['discussion_edit', null], - ]; this.response.template = 'discussion_edit.html'; - this.response.body = { ddoc: this.ddoc, path }; + this.response.body = { ddoc: this.ddoc }; } @param('did', Types.ObjectId) diff --git a/packages/hydrooj/src/model/discussion.ts b/packages/hydrooj/src/model/discussion.ts index 32156e83e..df201cea5 100644 --- a/packages/hydrooj/src/model/discussion.ts +++ b/packages/hydrooj/src/model/discussion.ts @@ -84,9 +84,11 @@ export async function get( } export async function edit(domainId: string, did: ObjectId, $set: Partial) { - await coll.insertOne({ - domainId, docId: did, content: $set.content, uid: $set.editor, ip: $set.ip, time: new Date(), - }); + if ($set.content) { + await coll.insertOne({ + domainId, docId: did, content: $set.content, uid: $set.editor, ip: $set.ip, time: new Date(), + }); + } return document.set(domainId, document.TYPE_DISCUSSION, did, $set); } diff --git a/packages/hydrooj/src/upgrade.ts b/packages/hydrooj/src/upgrade.ts index e3abafa1c..71fdf3c20 100644 --- a/packages/hydrooj/src/upgrade.ts +++ b/packages/hydrooj/src/upgrade.ts @@ -615,4 +615,8 @@ export const coreScripts: MigrationScript[] = [ }); return true; }, + async function _94_95() { + await discussion.coll.deleteMany({ content: { $not: { $type: 'string' } } }); + return true; + }, ];