diff --git a/lib/mediaPlayer/generateCommentsObjects.js b/lib/mediaPlayer/generateCommentsObjects.js index b936b668..ff8acbe8 100644 --- a/lib/mediaPlayer/generateCommentsObjects.js +++ b/lib/mediaPlayer/generateCommentsObjects.js @@ -11,7 +11,7 @@ async function generateComments(uploadId){ upload: uploadId, visibility: 'public', inResponseTo : {$exists: false} - }).populate({path: 'responses commenter', populate: {path: 'commenter'}}); + }).populate({path: 'responses commenter', match: { visibility: { $ne: 'removed' } }, populate: {path: 'commenter'}}); let commentCount = 0; for(const comment of comments){ diff --git a/views/media.pug b/views/media.pug index c8a6e144..fa0c8b00 100644 --- a/views/media.pug +++ b/views/media.pug @@ -779,15 +779,15 @@ block content a(href=`/user/${comment.commenter.channelUrl}` style="color:#d2d2d2;margin-right:5px;") #{comment.commenter.channelName || comment.commenter.channelUrl} p.fw(style="display:inline-block;") - #{comment.timeAgo}   if user && !viewingUserIsBlocked - a.reply-link(style="cursor:pointer") Reply + a.reply-link(style="cursor:pointer") Comment in Thread // delete button // if uploader or admin or commenter, let them delete comment if isUploaderOrAdmin || ( user && comment.commenter._id == user._id ) - a.delete-comment-button(style="margin-left:9px;cursor:pointer;" commentId=comment._id) Delete + a.delete-comment-thread-button(style="margin-left:9px;cursor:pointer;" commentId=comment._id) Delete - if isUploader && !comment.commenter.isBlocked + if isUploader && !comment.commenter.isBlocked && ( user && comment.commenter._id != user._id ) a.block-user-button(style="margin-left:9px;cursor:pointer;" blockedusername=comment.commenter.channelUrl) Block User - if isUploader && comment.commenter.isBlocked + if isUploader && comment.commenter.isBlocked && ( user && comment.commenter._id != user._id ) a.unblock-user-button(style="margin-left:9px;cursor:pointer;" blockedusername=comment.commenter.channelUrl) Unblock User @@ -813,6 +813,17 @@ block content p.fw(style="text-align:left;display:inline-block;") a(href=`/user/${responseComment.commenter.channelUrl}` style="color:#d2d2d2;margin-right:5px;") #{responseComment.commenter.channelName || responseComment.commenter.channelUrl} p.fw(style="display:inline-block;") - #{responseComment.timeAgo}   + // delete button + // if uploader, admin or commenter, let them delete comment + if isUploaderOrAdmin || ( user && comment.commenter._id == user._id ) + a.delete-thread-comment-button(style="margin-left:9px;cursor:pointer;" commentId=responseComment._id) Delete + + // if uploader, allow (un)blocking a user + // uploader cannot (un)block themselves + if isUploader && !comment.commenter.isBlocked && ( user && comment.commenter._id != user._id ) + a.block-user-button(style="margin-left:9px;cursor:pointer;" blockedusername=comment.commenter.channelUrl) Block User + if isUploader && comment.commenter.isBlocked && ( user && comment.commenter._id != user._id ) + a.unblock-user-button(style="margin-left:9px;cursor:pointer;" blockedusername=comment.commenter.channelUrl) Unblock User p.fw(style="text-align:left;") #{responseComment.text} //div.reply-container(style="display:none") diff --git a/views/mediaPlayerPartials/deleteCommentAndBlockUnblockUserJs.pug b/views/mediaPlayerPartials/deleteCommentAndBlockUnblockUserJs.pug index 77956368..88d2d1c1 100644 --- a/views/mediaPlayerPartials/deleteCommentAndBlockUnblockUserJs.pug +++ b/views/mediaPlayerPartials/deleteCommentAndBlockUnblockUserJs.pug @@ -1,6 +1,6 @@ script. $(function(){ - function deleteComment(commentId, commentThread) { + function deleteComment(commentId, comment) { var upload = '#{upload._id}'; @@ -21,7 +21,7 @@ script. swal('Comment deleted!'); - commentThread.hide(); + comment.hide(); // remove comment @@ -36,7 +36,7 @@ script. } - $('.delete-comment-button').on('release click', function (e) { + $('.delete-comment-thread-button').on('release click', function (e) { var commentThread = $(this).parent().parent().parent().parent(); @@ -60,6 +60,30 @@ script. }) }) + $('.delete-thread-comment-button').on('release click', function (e) { + + var commentInThread = $(this).parent().parent().parent(); + + var commentId = $(this).attr('commentId'); + + // dont move browser + e.preventDefault(); + + swal({ + title: "Delete Comment", + text: "Are you sure you want to delete the comment?", + type: 'warning', + showCancelButton: true, + confirmButtonText: 'Delete Comment' + }).then(function (result) { + if (result.value) { + deleteComment(commentId, commentInThread) + } else { + swal.close(); + } + }) + }) + function blockUser(blockedUsername) { var csrf = '#{_csrf}'