Fix wrong overwriting of updatedDate of Issues and Pull requests (#3053)

This commit is contained in:
Naoki Takezoe
2022-05-02 22:11:46 +09:00
committed by GitHub
parent 504e651828
commit e401d30159
3 changed files with 8 additions and 6 deletions

View File

@@ -258,7 +258,7 @@ trait IssuesControllerBase extends ControllerBase {
loginAccount =>
getComment(repository.owner, repository.name, params("id")).map { comment =>
if (isEditableContent(repository.owner, repository.name, comment.commentedUserName, loginAccount)) {
updateComment(comment.issueId, comment.commentId, form.content)
updateComment(repository.owner, repository.name, comment.issueId, comment.commentId, form.content)
redirect(s"/${repository.owner}/${repository.name}/issue_comments/_data/${comment.commentId}")
} else Unauthorized()
} getOrElse NotFound()

View File

@@ -165,7 +165,7 @@ trait HandleCommentService {
content match {
case Some(content) =>
// Update comment
val _commentId = Some(updateComment(issue.issueId, commentId.toInt, content))
val _commentId = Some(updateComment(owner, name, issue.issueId, commentId.toInt, content))
// Record comment activity
val commentInfo = if (issue.isPullRequest) {
PullRequestCommentInfo(owner, name, userName, content, issue.issueId)

View File

@@ -509,7 +509,7 @@ trait IssuesService {
content: String,
action: String
)(implicit s: Session): Int = {
Issues.filter(_.issueId === issueId.bind).map(_.updatedDate).update(currentDate)
Issues.filter(_.byPrimaryKey(owner, repository, issueId)).map(_.updatedDate).update(currentDate)
IssueComments returning IssueComments.map(_.commentId) insert IssueComment(
userName = owner,
repositoryName = repository,
@@ -635,8 +635,10 @@ trait IssuesService {
.update(priorityId, currentDate)
}
def updateComment(issueId: Int, commentId: Int, content: String)(implicit s: Session): Int = {
Issues.filter(_.issueId === issueId.bind).map(_.updatedDate).update(currentDate)
def updateComment(owner: String, repository: String, issueId: Int, commentId: Int, content: String)(
implicit s: Session
): Int = {
Issues.filter(_.byPrimaryKey(owner, repository, issueId)).map(_.updatedDate).update(currentDate)
IssueComments.filter(_.byPrimaryKey(commentId)).map(t => (t.content, t.updatedDate)).update(content, currentDate)
}
@@ -644,7 +646,7 @@ trait IssuesService {
implicit context: Context,
s: Session
): Int = {
Issues.filter(_.issueId === issueId.bind).map(_.updatedDate).update(currentDate)
Issues.filter(_.byPrimaryKey(owner, repository, issueId)).map(_.updatedDate).update(currentDate)
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")