From 127238c950d234249ed7d846ff51d9d78bf06487 Mon Sep 17 00:00:00 2001 From: undefined Date: Tue, 21 Mar 2023 20:45:24 +0800 Subject: [PATCH] core: discussion_raw: add existance check --- packages/hydrooj/src/handler/discussion.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/hydrooj/src/handler/discussion.ts b/packages/hydrooj/src/handler/discussion.ts index 4bec97ca..ce8fa1e8 100644 --- a/packages/hydrooj/src/handler/discussion.ts +++ b/packages/hydrooj/src/handler/discussion.ts @@ -363,7 +363,12 @@ class DiscussionRawHandler extends DiscussionHandler { this.response.body.history = await discussion.getHistory(domainId, drrid || drid || did); } else { const [doc] = await discussion.getHistory(domainId, drrid || drid || did, ts ? { time: new Date(ts) } : {}); - if (!doc && ts) throw new DiscussionNotFoundError(drrid || drid || did); + if (!doc) { + if (ts) throw new DiscussionNotFoundError(drrid || drid || did); + if (drrid && !this.drrdoc) throw new DiscussionNotFoundError(drrid); + if (drid && !this.drdoc) throw new DiscussionNotFoundError(drid); + if (did && !this.ddoc) throw new DiscussionNotFoundError(did); + } this.response.type = 'text/markdown'; this.response.body = doc ? doc.content : drrid ? this.drrdoc.content : drid ? this.drdoc.content : this.ddoc.content; }