Преглед изворни кода

Throw error if thread is locked

sbkwgh пре 8 година
родитељ
комит
c5e978fcc3
1 измењених фајлова са 2 додато и 1 уклоњено
  1. 2 1
      routes/post.js

+ 2 - 1
routes/post.js

@@ -128,6 +128,7 @@ router.post('/', async (req, res) => {
 		}})
 
 		if(!thread) throw Errors.invalidParameter('threadId', 'thread does not exist')
+		if(thread.locked) throw Errors.threadLocked
 
 		if(req.body.replyingToId) {
 			replyingToPost = await Post.findById(
@@ -205,7 +206,7 @@ router.post('/', async (req, res) => {
 			res.json({
 				errors: validationErrors
 			})
-		} else if(e.name === 'invalidParameter') {
+		} else if(e.name === 'invalidParameter' || e.name === 'threadLocked') {
 			res.status(400)
 			res.json({
 				errors: [e]