From bd63e1e75e2d6e98115d4e3c042b2891312671f0 Mon Sep 17 00:00:00 2001 From: KOUNOIKE Yuusuke Date: Tue, 31 Oct 2017 22:39:19 +0900 Subject: [PATCH] fix #1763 when deleting comment, close_comment => close / reopen_comment => reopen. not delete. --- .../scala/gitbucket/core/service/IssuesService.scala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/scala/gitbucket/core/service/IssuesService.scala b/src/main/scala/gitbucket/core/service/IssuesService.scala index 18ab1d163..5d72a332b 100644 --- a/src/main/scala/gitbucket/core/service/IssuesService.scala +++ b/src/main/scala/gitbucket/core/service/IssuesService.scala @@ -369,7 +369,14 @@ trait IssuesService { def deleteComment(issueId: Int, commentId: Int)(implicit s: Session): Int = { Issues.filter(_.issueId === issueId.bind).map(_.updatedDate).update(currentDate) - IssueComments.filter(_.byPrimaryKey(commentId)).delete + IssueComments.filter(_.byPrimaryKey(commentId)).firstOption match { + case Some(c) if c.action == "reopen_comment" => + IssueComments.filter(_.byPrimaryKey(commentId)).map(t => (t.content, t.action)).update("Reopen", "reopen") + case Some(c) if c.action == "close_comment" => + IssueComments.filter(_.byPrimaryKey(commentId)).map(t => (t.content, t.action)).update("Close", "close") + case Some(_) => + IssueComments.filter(_.byPrimaryKey(commentId)).delete + } } def updateClosed(owner: String, repository: String, issueId: Int, closed: Boolean)(implicit s: Session): Int = {