Skip to content

Commit

Permalink
Merge pull request #179 from SquareTable/164-tempimagepostcomment-sho…
Browse files Browse the repository at this point in the history
…uld-return-newly-made-comment

164 tempimagepostcomment should return newly made comment
  • Loading branch information
Sebastian-Webster authored Oct 10, 2023
2 parents e412e4f + 209c33d commit 1a32e59
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 @@ -1683,10 +1683,12 @@ class TempController {
if (result) {
const objectId = new mongoose.Types.ObjectId()
console.log(objectId)
var commentForPost = {commentId: objectId, commenterId: userId, commentsText: comment, commentUpVotes: [], commentDownVotes: [], commentReplies: [], datePosted: Date.now()}
const commentForPost = {commentId: objectId, commenterId: userId, commentsText: comment, commentUpVotes: [], commentDownVotes: [], commentReplies: [], datePosted: Date.now()}
ImagePost.findOneAndUpdate({_id: {$eq: postId}}, { $push: { comments: 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 comment object:', commentForPost, 'to comments field for image with id:', postId, '. The error was:', err)
Expand Down

0 comments on commit 1a32e59

Please sign in to comment.