Browse Source

Delete comments on deleting article in discussion

pull/6/head
Menci 6 years ago
parent
commit
2eff707f6d
  1. 4
      modules/discussion.js

4
modules/discussion.js

@ -201,6 +201,10 @@ app.post('/article/:id/delete', async (req, res) => {
if (!await article.isAllowedEditBy(res.locals.user)) throw new ErrorMessage('您没有权限进行此操作。'); if (!await article.isAllowedEditBy(res.locals.user)) throw new ErrorMessage('您没有权限进行此操作。');
} }
await Promise.all((await ArticleComment.find({
article_id: article.id
})).map(comment => comment.destroy()))
await article.destroy(); await article.destroy();
res.redirect(syzoj.utils.makeUrl(['discussion', 'global'])); res.redirect(syzoj.utils.makeUrl(['discussion', 'global']));

Loading…
Cancel
Save