From 81248feeb9c44494062785b49e8db7fab61b11ae Mon Sep 17 00:00:00 2001 From: Sebastian Webster Date: Thu, 12 Oct 2023 16:32:05 +1300 Subject: [PATCH 01/15] isOwner is returned from temp/pollpostcomment --- controllers/Temp.js | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/Temp.js b/controllers/Temp.js index 6dcbfbc5..6d1869c3 100644 --- a/controllers/Temp.js +++ b/controllers/Temp.js @@ -718,6 +718,7 @@ class TempController { Poll.findOneAndUpdate({_id: {$eq: postId}}, { $push: { comments: commentForPost } }).then(function(){ commentForPost.commentId = String(commentForPost.commentId) commentForPost.commenterId = String(commentForPost.commenterId) + commentForPost.isOwner = true; return resolve(HTTPWTHandler.OK('Comment upload successful', commentForPost)) }) .catch(err => { From 0f8e8da80d2247da816e67cd9728f980cceebfc7 Mon Sep 17 00:00:00 2001 From: Sebastian Webster Date: Thu, 12 Oct 2023 16:34:16 +1300 Subject: [PATCH 02/15] temp/pollpostcommentreply now returns isOwner --- controllers/Temp.js | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/Temp.js b/controllers/Temp.js index 6d1869c3..056085e3 100644 --- a/controllers/Temp.js +++ b/controllers/Temp.js @@ -777,6 +777,7 @@ class TempController { Poll.findOneAndUpdate({_id: {$eq: postId}}, { $push: { [`comments.${sentIndex}.commentReplies`]: commentForPost } }).then(function(){ commentForPost.commentId = String(commentForPost.commentId) commentForPost.commenterId = String(commentForPost.commenterId) + commentForPost.isOwner = true; return resolve(HTTPWTHandler.OK('Comment upload successful', commentForPost)) }) .catch(err => { From fceac7f7f9b876da3f48e270446de9e3fc08e998 Mon Sep 17 00:00:00 2001 From: Sebastian Webster Date: Thu, 12 Oct 2023 16:35:22 +1300 Subject: [PATCH 03/15] temp/searchforpollcomments now returns isOwner property --- controllers/Temp.js | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/Temp.js b/controllers/Temp.js index 056085e3..9671d1ef 100644 --- a/controllers/Temp.js +++ b/controllers/Temp.js @@ -842,6 +842,7 @@ class TempController { const modifiedNameSendBackObject = nameSendBackObject.map(item => { item.commentId = String(item.commentId) item.commenterId = String(item.commenterId) + item.isOwner = String(userId) === String(item.commenterId) return item }) return resolve(HTTPWTHandler.OK('Comment search successful', modifiedNameSendBackObject)) From 05a2b846e0bf07c143f857f1be0af6ae7b5bf41c Mon Sep 17 00:00:00 2001 From: Sebastian Webster Date: Thu, 12 Oct 2023 16:37:25 +1300 Subject: [PATCH 04/15] temp/getsinglepollcomment returns isOwner property --- controllers/Temp.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/Temp.js b/controllers/Temp.js index 9671d1ef..1ef42a48 100644 --- a/controllers/Temp.js +++ b/controllers/Temp.js @@ -1210,7 +1210,8 @@ class TempController { datePosted: comments[index].datePosted, profileImageKey: result.profileImageKey, commentUpVoted: commentUpVoted, - commentDownVoted: commentDownVoted + commentDownVoted: commentDownVoted, + isOwner: String(comments[index].commenterId) === String(userId) }) sendResponse(nameSendBackObject) } else { From 5ac16d370d0c2482d30a435546d4d7baf84804ff Mon Sep 17 00:00:00 2001 From: Sebastian Webster Date: Thu, 12 Oct 2023 16:39:33 +1300 Subject: [PATCH 05/15] temp/searchforpollcommentreplies now returns isOwner property --- controllers/Temp.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/controllers/Temp.js b/controllers/Temp.js index 1ef42a48..1c7c96b9 100644 --- a/controllers/Temp.js +++ b/controllers/Temp.js @@ -1311,12 +1311,15 @@ class TempController { datePosted: item.datePosted, profileImageKey: user.profileImageKey, commentUpVoted: commentUpVoted, - commentDownVoted: commentDownVoted + commentDownVoted: commentDownVoted, + isOwner: String(item.commenterId) === String(userId) }) } else { console.error("A comment exists but it's creator's account has been deleted. This comment must be deleted immediately. Comment id:", item._id, ' User Id:', item.commenterId) } } + + sendResponse(nameSendBackObject) }).catch(error => { console.error('An error occurred while finding users with an id inside of this array:', uniqueUsers, '. The error was:', error) return resolve(HTTPWTHandler.serverError('An error occurred while finding comment creators. Please try again.')) From 43f01b8c703dc7bec731807eb2fb4586137920ef Mon Sep 17 00:00:00 2001 From: Sebastian Webster Date: Thu, 12 Oct 2023 20:47:54 +1300 Subject: [PATCH 06/15] temp/imagepostcomment now returns isOwner property --- controllers/Temp.js | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/Temp.js b/controllers/Temp.js index 1c7c96b9..a4a03ab0 100644 --- a/controllers/Temp.js +++ b/controllers/Temp.js @@ -1695,6 +1695,7 @@ class TempController { console.log("SUCCESS1") commentForPost.commentId = String(commentForPost.commentId) commentForPost.commenterId = String(commentForPost.commenterId) + commentForPost.isOwner = true; return resolve(HTTPWTHandler.OK('Comment upload successful', commentForPost)) }) .catch(err => { From 1c0f51f4f0d190166b64e84dfe3475c314bf50ae Mon Sep 17 00:00:00 2001 From: Sebastian Webster Date: Thu, 12 Oct 2023 20:48:35 +1300 Subject: [PATCH 07/15] temp/imagepostcommentreply now returns isOwner property --- controllers/Temp.js | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/Temp.js b/controllers/Temp.js index a4a03ab0..c0201151 100644 --- a/controllers/Temp.js +++ b/controllers/Temp.js @@ -1763,6 +1763,7 @@ class TempController { console.log("SUCCESS1") commentForPost.commentId = String(commentForPost.commentId) commentForPost.commenterId = String(commentForPost.commenterId) + commentForPost.isOwner = true; return resolve(HTTPWTHandler.OK('Comment upload successful', commentForPost)) }) .catch(err => { From 023acf055e553e63f9dc81e5b4eac48047f6b939 Mon Sep 17 00:00:00 2001 From: Sebastian Webster Date: Thu, 12 Oct 2023 20:49:38 +1300 Subject: [PATCH 08/15] temp/getimagepostcomments now returns isOwner property --- controllers/Temp.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/Temp.js b/controllers/Temp.js index c0201151..7ca7510b 100644 --- a/controllers/Temp.js +++ b/controllers/Temp.js @@ -1865,7 +1865,8 @@ class TempController { datePosted: comment.datePosted, profileImageKey: commentCreator.profileImageKey, commentUpVoted: commentUpVoted, - commentDownVoted: commentDownVoted + commentDownVoted: commentDownVoted, + isOwner: String(comment.commenterId) === String(userId) }) } else { console.error('A comment was found from user with id:', comment.commenterId, ' but the user with that id could not be found. This comment should be deleted immediately.') From fa374c713d3a850c2fc7405a745f979c485b5858 Mon Sep 17 00:00:00 2001 From: Sebastian Webster Date: Thu, 12 Oct 2023 20:50:57 +1300 Subject: [PATCH 09/15] temp/getsingleimagecomment now returns isOwner property --- controllers/Temp.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/Temp.js b/controllers/Temp.js index 7ca7510b..4b216813 100644 --- a/controllers/Temp.js +++ b/controllers/Temp.js @@ -2120,7 +2120,8 @@ class TempController { datePosted: comment.datePosted, profileImageKey: result.profileImageKey, commentUpVoted: commentUpVoted, - commentDownVoted: commentDownVoted + commentDownVoted: commentDownVoted, + isOwner: String(comment.commenterId) === String(userId) }) sendResponse(nameSendBackObject) } else { From f5bcb0acfcc4800b6dbe5da5dba68ab7638714dc Mon Sep 17 00:00:00 2001 From: Sebastian Webster Date: Thu, 12 Oct 2023 20:51:50 +1300 Subject: [PATCH 10/15] temp/searchforimagecommentreplies now returns isOwner property --- controllers/Temp.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/Temp.js b/controllers/Temp.js index 4b216813..8e1aedfd 100644 --- a/controllers/Temp.js +++ b/controllers/Temp.js @@ -2253,7 +2253,8 @@ class TempController { datePosted: comment.datePosted, profileImageKey: creator.profileImageKey, commentUpVoted: commentUpVoted, - commentDownVoted: commentDownVoted + commentDownVoted: commentDownVoted, + isOwner: String(comment.commenterId) === String(userId) }) } else { console.error('A comment was found with id:', comment.commentId, 'that was from a user with id:', comment.commenterId, '. That user cannot be found in the database, and such this comment should be deleted immediately.') From 41f1d5d849b85f0f5ce7d1ba28be85025db311f8 Mon Sep 17 00:00:00 2001 From: Sebastian Webster Date: Thu, 12 Oct 2023 20:52:31 +1300 Subject: [PATCH 11/15] temp/threadpostcomment now returns isOwner property --- controllers/Temp.js | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/Temp.js b/controllers/Temp.js index 8e1aedfd..a739750b 100644 --- a/controllers/Temp.js +++ b/controllers/Temp.js @@ -3531,6 +3531,7 @@ class TempController { console.log("SUCCESS1") commentForPost.commentId = String(commentForPost.commentId) commentForPost.commenterId = String(commentForPost.commenterId) + commentForPost.isOwner = true; return resolve(HTTPWTHandler.OK('Comment upload successful', commentForPost)) }) .catch(err => { From 968276918dbf2c642f648c91e2dbb80733b81bb9 Mon Sep 17 00:00:00 2001 From: Sebastian Webster Date: Thu, 12 Oct 2023 20:53:07 +1300 Subject: [PATCH 12/15] temp/threadpostcommentreply now returns isOwner property --- controllers/Temp.js | 1 + 1 file changed, 1 insertion(+) diff --git a/controllers/Temp.js b/controllers/Temp.js index a739750b..90144dec 100644 --- a/controllers/Temp.js +++ b/controllers/Temp.js @@ -3597,6 +3597,7 @@ class TempController { console.log("SUCCESS1") commentForPost.commentId = String(commentForPost.commentId) commentForPost.commenterId = String(commentForPost.commenterId) + commentForPost.isOwner = true; return resolve(HTTPWTHandler.OK('Comment upload successful', commentForPost)) }) .catch(err => { From 588be14c5aa257d71a21867248a469cd7944d666 Mon Sep 17 00:00:00 2001 From: Sebastian Webster Date: Thu, 12 Oct 2023 20:54:49 +1300 Subject: [PATCH 13/15] temp/searchforthreadcomments now returns isOwner property --- controllers/Temp.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/controllers/Temp.js b/controllers/Temp.js index 90144dec..0f973c92 100644 --- a/controllers/Temp.js +++ b/controllers/Temp.js @@ -3662,7 +3662,20 @@ class TempController { if (data.comments[index].commentDownVotes.includes(userId)) { commentDownVoted = true } - nameSendBackObject.push({commentId: String(data.comments[index].commentId), commenterName: result.name, commenterDisplayName: result.displayName, commentText: data.comments[index].commentsText, commentUpVotes: commentUpVotes, commentDownVotes: data.comments[index].commentDownVotes, commentReplies: data.comments[index].commentReplies.length, datePosted: data.comments[index].datePosted, profileImageKey: result.profileImageKey, commentUpVoted: commentUpVoted, commentDownVoted: commentDownVoted}) + nameSendBackObject.push({ + commentId: String(data.comments[index].commentId), + commenterName: result.name, + commenterDisplayName: result.displayName, + commentText: data.comments[index].commentsText, + commentUpVotes: commentUpVotes, + commentDownVotes: data.comments[index].commentDownVotes, + commentReplies: data.comments[index].commentReplies.length, + datePosted: data.comments[index].datePosted, + profileImageKey: result.profileImageKey, + commentUpVoted: commentUpVoted, + commentDownVoted: commentDownVoted, + isOwner: String(data.comments[index].commenterId) === String(userId) + }) } else { console.error('A comment was found on thread post with id:', postId, " and the comment creator cannot be found. The comment creator's id is:", comments[index].commenterId) return resolve(HTTPWTHandler.serverError('An error occurred while checking for comment creator')) From c6b09679f594b204969af636036bac74dd95c89b Mon Sep 17 00:00:00 2001 From: Sebastian Webster Date: Thu, 12 Oct 2023 20:55:36 +1300 Subject: [PATCH 14/15] temp/getsinglethreadcomment now returns isOwner property --- controllers/Temp.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/Temp.js b/controllers/Temp.js index 0f973c92..a5c67118 100644 --- a/controllers/Temp.js +++ b/controllers/Temp.js @@ -3773,7 +3773,8 @@ class TempController { datePosted: commentdatePosted, profileImageKey: creator.profileImageKey, commentUpVoted: commentUpVoted, - commentDownVoted: commentDownVoted + commentDownVoted: commentDownVoted, + isOwner: String(comment.commenterId) === String(userId) }) sendResponse(nameSendBackObject) }).catch(error => { From b1410f8d721a4c9e1f9a08f6a7b92b3d2352527c Mon Sep 17 00:00:00 2001 From: Sebastian Webster Date: Thu, 12 Oct 2023 20:56:26 +1300 Subject: [PATCH 15/15] temp/searchforthreadcommentreplies now returns isOwner property --- controllers/Temp.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controllers/Temp.js b/controllers/Temp.js index a5c67118..6716599e 100644 --- a/controllers/Temp.js +++ b/controllers/Temp.js @@ -3865,7 +3865,8 @@ class TempController { datePosted: comment.datePosted, profileImageKey: commentCreator.profileImageKey, commentUpVoted: commentUpVoted, - commentDownVoted: commentDownVoted + commentDownVoted: commentDownVoted, + isOwner: String(comment.commenterId) === String(userId) }) } })