Improve issue comment management (#2588)
1 parent 1b32e13 commit 04c8f8b864f007e3e08781b78bfe8a8e2bd7ae26
@onukura onukura authored on 6 Dec 2020
GitHub committed on 6 Dec 2020
Showing 7 changed files
View
14
src/main/scala/gitbucket/core/controller/IssuesController.scala
getPriorities(owner, name),
getLabels(owner, name),
isIssueEditable(repository),
isIssueManageable(repository),
isIssueCommentManageable(repository),
repository
)
}
} getOrElse NotFound()
ajaxPost("/:owner/:repository/issue_comments/delete/:id")(readableUsersOnly { repository =>
defining(repository.owner, repository.name) {
case (owner, name) =>
getComment(owner, name, params("id")).map { comment =>
if (isEditableContent(owner, name, comment.commentedUserName)) {
Ok(deleteComment(comment.issueId, comment.commentId))
if (isDeletableComment(owner, name, comment.commentedUserName)) {
Ok(deleteComment(repository.owner, repository.name, comment.issueId, comment.commentId))
} else Unauthorized()
} getOrElse NotFound()
}
})
implicit context: Context
): Boolean = {
hasDeveloperRole(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
}
 
/**
* Tests whether an issue comment is deletable by a logged-in user.
*/
private def isDeletableComment(owner: String, repository: String, author: String)(
implicit context: Context
): Boolean = {
hasOwnerRole(owner, repository, context.loginAccount) || author == context.loginAccount.get.userName
}
}
View
2
■■■
src/main/scala/gitbucket/core/service/HandleCommentService.scala
s: Session
): Option[IssueComment] = context.loginAccount.flatMap { _ =>
comment.action match {
case "comment" =>
val deleteResult = deleteComment(comment.issueId, comment.commentId)
val deleteResult = deleteComment(repoInfo.owner, repoInfo.name, comment.issueId, comment.commentId)
val registry = PluginRegistry()
val hooks: Seq[IssueHook] = if (issue.isPullRequest) registry.getPullRequestHooks else registry.getIssueHooks
hooks.foreach(_.deletedComment(comment.commentId, issue, repoInfo))
deleteResult match {
View
src/main/scala/gitbucket/core/service/IssueCreationService.scala
View
src/main/scala/gitbucket/core/service/IssuesService.scala
View
src/main/twirl/gitbucket/core/issues/commentlist.scala.html
View
src/main/twirl/gitbucket/core/issues/issue.scala.html
View
src/main/webapp/assets/common/css/gitbucket.css