From 5f86655ba529577e808d9960583849fd844a15a6 Mon Sep 17 00:00:00 2001 From: Sebastian-Webster Date: Tue, 10 Oct 2023 18:28:31 +1300 Subject: [PATCH] temp/threadpostcommentreply now returns newly made comment --- controllers/Temp.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/controllers/Temp.js b/controllers/Temp.js index c99e4e71..668b1719 100644 --- a/controllers/Temp.js +++ b/controllers/Temp.js @@ -3569,10 +3569,12 @@ class TempController { const objectId = new mongoose.Types.ObjectId() console.log(objectId) - var commentForPost = {commentId: objectId, commenterId: userId, commentsText: comment, commentUpVotes: [], commentDownVotes: [], datePosted: Date.now()} + const commentForPost = {commentId: objectId, commenterId: userId, commentsText: comment, commentUpVotes: [], commentDownVotes: [], datePosted: Date.now()} Thread.findOneAndUpdate({_id: {$eq: postId}}, { $push: { [`comments.${sentIndex}.commentReplies`]: commentForPost } }).then(function(){ console.log("SUCCESS1") - return resolve(HTTPWTHandler.OK('Comment upload successful')) + commentForPost.commentId = String(commentForPost.commentId) + commentForPost.commenterId = String(commentForPost.commenterId) + return resolve(HTTPWTHandler.OK('Comment upload successful', commentForPost)) }) .catch(err => { console.error('An error occurred while pushing:', commentForPost, 'to:', `comments.${sentIndex}.commentReplies`, ' for thread with id:', postId, '. The error was:', err)