From 3973ee999d2e54a27dbb7394954ab807416fe76f Mon Sep 17 00:00:00 2001 From: Sebastian-Webster Date: Tue, 10 Oct 2023 18:26:33 +1300 Subject: [PATCH] temp/pollpostcommentreply now returns newly made comment --- controllers/Temp.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/controllers/Temp.js b/controllers/Temp.js index c99e4e71..e59a1336 100644 --- a/controllers/Temp.js +++ b/controllers/Temp.js @@ -768,11 +768,13 @@ class TempController { if (data) { var comments = data.comments async function findThreads(sentIndex) { - var objectId = new mongoose.Types.ObjectId() + 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()} Poll.findOneAndUpdate({_id: {$eq: postId}}, { $push: { [`comments.${sentIndex}.commentReplies`]: commentForPost } }).then(function(){ - 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 occured while adding reply to poll comment. Comment reply was:', commentForPost, '. The error was:', err)