From: David Svantesson Date: Sun, 27 Oct 2019 23:36:28 +0000 (+0100) Subject: Fix deadline on update issue or PR via API (#8699) X-Git-Tag: v1.9.5~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b2c3a7d79f87fb443ff2b479ce9c280f99262dbe;p=gitea.git Fix deadline on update issue or PR via API (#8699) --- diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index daaa3d5985..af320a39eb 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -310,14 +310,13 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) { } // Update the deadline - var deadlineUnix util.TimeStamp if form.Deadline != nil && !form.Deadline.IsZero() && ctx.Repo.CanWrite(models.UnitTypeIssues) { - deadlineUnix = util.TimeStamp(form.Deadline.Unix()) - } - - if err := models.UpdateIssueDeadline(issue, deadlineUnix, ctx.User); err != nil { - ctx.Error(500, "UpdateIssueDeadline", err) - return + deadlineUnix := util.TimeStamp(form.Deadline.Unix()) + if err := models.UpdateIssueDeadline(issue, deadlineUnix, ctx.User); err != nil { + ctx.Error(500, "UpdateIssueDeadline", err) + return + } + issue.DeadlineUnix = deadlineUnix } // Add/delete assignees diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index d99c9a00c9..4ad3479fd0 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -375,14 +375,13 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) { } // Update Deadline - var deadlineUnix util.TimeStamp if form.Deadline != nil && !form.Deadline.IsZero() { - deadlineUnix = util.TimeStamp(form.Deadline.Unix()) - } - - if err := models.UpdateIssueDeadline(issue, deadlineUnix, ctx.User); err != nil { - ctx.Error(500, "UpdateIssueDeadline", err) - return + deadlineUnix := util.TimeStamp(form.Deadline.Unix()) + if err := models.UpdateIssueDeadline(issue, deadlineUnix, ctx.User); err != nil { + ctx.Error(500, "UpdateIssueDeadline", err) + return + } + issue.DeadlineUnix = deadlineUnix } // Add/delete assignees