comments: forbig removal of comments by anyone except the owners.

This commit is contained in:
Milka Kuzminski 2021-02-23 08:44:25 +01:00
parent 538b57d031
commit f8f3a39d93
2 changed files with 8 additions and 0 deletions

View file

@ -674,6 +674,10 @@ class RepoCommitsView(RepoAppView):
is_repo_comment = comment.repo.repo_id == self.db_repo.repo_id
comment_repo_admin = is_repo_admin and is_repo_comment
if comment.draft and not comment_owner:
# We never allow to delete draft comments for other than owners
raise HTTPNotFound()
if super_admin or comment_owner or comment_repo_admin:
CommentsModel().delete(comment=comment, auth_user=self._rhodecode_user)
Session().commit()

View file

@ -1748,6 +1748,10 @@ class RepoPullRequestsView(RepoAppView, DataGridAppView):
is_repo_comment = comment.repo.repo_name == self.db_repo_name
comment_repo_admin = is_repo_admin and is_repo_comment
if comment.draft and not comment_owner:
# We never allow to delete draft comments for other than owners
raise HTTPNotFound()
if super_admin or comment_owner or comment_repo_admin:
old_calculated_status = comment.pull_request.calculated_review_status()
CommentsModel().delete(comment=comment, auth_user=self._rhodecode_user)