Node.js based forum software built for the modern web
fix(posts): prevent phantom post objects when toPid references non-existent parent
Julian Lam228730f3f019
diff --git a/src/posts/create.js b/src/posts/create.jsindex 72efd0c64c..b218ad3b99 100644--- a/src/posts/create.js+++ b/src/posts/create.js@@ -82,6 +82,11 @@ module.exports = function (Posts) {if (!postData.toPid) {return;}+ const exists = await Posts.exists(postData.toPid);+ if (!exists) {+ return;+ }+await Promise.all([db.sortedSetAdd(`pid:${postData.toPid}:replies`, timestamp, postData.pid),db.incrObjectField(`post:${postData.toPid}`, 'replies'),