core: discussion_raw: add existance check

pull/544/head
undefined 2 years ago
parent 4727e89d1d
commit 127238c950
No known key found for this signature in database

@ -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;
}

Loading…
Cancel
Save