core: discussion_raw: add existance check

This commit is contained in:
undefined committed 2023-03-21 20:45:24 +08:00
1 parent 4727e89d1d
commit 127238c950
1 file changed
+6 -1
+6 -1
View File
@@ -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;
}