]> source.dussan.org Git - gitea.git/commitdiff
Check if the `due_date` is nil when editing issues (#32035)
authorZettat123 <zettat123@gmail.com>
Sat, 14 Sep 2024 16:40:36 +0000 (00:40 +0800)
committerGitHub <noreply@github.com>
Sat, 14 Sep 2024 16:40:36 +0000 (12:40 -0400)
routers/api/v1/repo/issue.go

index c53eb0719055a286f0cd1488b5426e8018d1196e..c1218440e5958826ca2179c9087ffb140bba9256 100644 (file)
@@ -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 {