From b2c3a7d79f87fb443ff2b479ce9c280f99262dbe Mon Sep 17 00:00:00 2001 From: David Svantesson Date: Mon, 28 Oct 2019 00:36:28 +0100 Subject: [PATCH] Fix deadline on update issue or PR via API (#8699) --- routers/api/v1/repo/issue.go | 13 ++++++------- routers/api/v1/repo/pull.go | 13 ++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index daaa3d59856..af320a39ebf 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 d99c9a00c99..4ad3479fd09 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