Skip to content

Commit

Permalink
temp/threadpostcommentreply now returns newly made comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian-Webster committed Oct 10, 2023
1 parent cb7ee59 commit 5f86655
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions controllers/Temp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5f86655

Please sign in to comment.