diff options
author | Zettat123 <zettat123@gmail.com> | 2024-09-15 00:40:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-14 12:40:36 -0400 |
commit | 3a51c37672d2fbad1f222922e75ce704d5a1ac71 (patch) | |
tree | e3a09b3ad65dfb1dc3fa21196e7bd07c633166ba /routers/api/v1 | |
parent | f05d9c98c4cb95e3a8a71bf3e2f8f4529e09f96f (diff) | |
download | gitea-3a51c37672d2fbad1f222922e75ce704d5a1ac71.tar.gz gitea-3a51c37672d2fbad1f222922e75ce704d5a1ac71.zip |
Check if the `due_date` is nil when editing issues (#32035)
Diffstat (limited to 'routers/api/v1')
-rw-r--r-- | routers/api/v1/repo/issue.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index c53eb07190..c1218440e5 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -833,10 +833,16 @@ func EditIssue(ctx *context.APIContext) { if (form.Deadline != nil || form.RemoveDeadline != nil) && canWrite { var deadlineUnix timeutil.TimeStamp - if (form.RemoveDeadline == nil || !*form.RemoveDeadline) && !form.Deadline.IsZero() { - deadline := time.Date(form.Deadline.Year(), form.Deadline.Month(), form.Deadline.Day(), - 23, 59, 59, 0, form.Deadline.Location()) - deadlineUnix = timeutil.TimeStamp(deadline.Unix()) + if form.RemoveDeadline == nil || !*form.RemoveDeadline { + if form.Deadline == nil { + ctx.Error(http.StatusBadRequest, "", "The due_date cannot be empty") + return + } + if !form.Deadline.IsZero() { + deadline := time.Date(form.Deadline.Year(), form.Deadline.Month(), form.Deadline.Day(), + 23, 59, 59, 0, form.Deadline.Location()) + deadlineUnix = timeutil.TimeStamp(deadline.Unix()) + } } if err := issues_model.UpdateIssueDeadline(ctx, issue, deadlineUnix, ctx.Doer); err != nil { |