diff --git a/kallithea/controllers/changeset.py b/kallithea/controllers/changeset.py --- a/kallithea/controllers/changeset.py +++ b/kallithea/controllers/changeset.py @@ -399,10 +399,14 @@ class ChangesetController(BaseRepoContro @LoginRequired() @HasRepoPermissionLevelDecorator('read') @jsonify - def delete_comment(self, repo_name, comment_id): + def delete_comment(self, repo_name, comment_id, pr_comment=False): co = ChangesetComment.get_or_404(comment_id) if co.repo.repo_name != repo_name: raise HTTPNotFound() + if pr_comment and co.pull_request.is_closed(): + # don't allow deleting comments on closed pull request + raise HTTPForbidden() + owner = co.author_id == request.authuser.user_id repo_admin = h.HasRepoPermissionLevel('admin')(repo_name) if h.HasPermissionAny('hg.admin')() or repo_admin or owner: diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py --- a/kallithea/controllers/pullrequests.py +++ b/kallithea/controllers/pullrequests.py @@ -716,13 +716,15 @@ class PullrequestsController(BaseRepoCon @HasRepoPermissionLevelDecorator('read') @jsonify def delete_comment(self, repo_name, comment_id): - co = ChangesetComment.get(comment_id) + co = ChangesetComment.get_or_404(comment_id) + if co.repo.repo_name != repo_name: + raise HTTPNotFound() if co.pull_request.is_closed(): # don't allow deleting comments on closed pull request raise HTTPForbidden() owner = co.author_id == request.authuser.user_id - repo_admin = h.HasRepoPermissionLevel('admin')(c.repo_name) + repo_admin = h.HasRepoPermissionLevel('admin')(repo_name) if h.HasPermissionAny('hg.admin')() or repo_admin or owner: ChangesetCommentsModel().delete(comment=co) Session().commit()