diff --git a/pkg/internal/server/api/articles_api.go b/pkg/internal/server/api/articles_api.go index 774d0a4..ccb4904 100644 --- a/pkg/internal/server/api/articles_api.go +++ b/pkg/internal/server/api/articles_api.go @@ -109,8 +109,10 @@ func editArticle(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusNotFound, err.Error()) } - if item.IsDraft && !data.IsDraft { + if item.IsDraft && !data.IsDraft && data.PublishedAt == nil { item.PublishedAt = lo.ToPtr(time.Now()) + } else { + item.PublishedAt = data.PublishedAt } body := models.PostArticleBody{ @@ -128,7 +130,6 @@ func editArticle(c *fiber.Ctx) error { item.Tags = data.Tags item.Categories = data.Categories item.IsDraft = data.IsDraft - item.PublishedAt = data.PublishedAt item.PublishedUntil = data.PublishedUntil if item, err := services.EditPost(item); err != nil { diff --git a/pkg/internal/server/api/stories_api.go b/pkg/internal/server/api/stories_api.go index 4d9010d..a05e758 100644 --- a/pkg/internal/server/api/stories_api.go +++ b/pkg/internal/server/api/stories_api.go @@ -128,8 +128,10 @@ func editStory(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusNotFound, err.Error()) } - if item.IsDraft && !data.IsDraft { + if item.IsDraft && !data.IsDraft && data.PublishedAt == nil { item.PublishedAt = lo.ToPtr(time.Now()) + } else { + item.PublishedAt = data.PublishedAt } body := models.PostStoryBody{ @@ -147,7 +149,6 @@ func editStory(c *fiber.Ctx) error { item.Language = services.DetectLanguage(data.Content) item.Tags = data.Tags item.Categories = data.Categories - item.PublishedAt = data.PublishedAt item.PublishedUntil = data.PublishedUntil item.IsDraft = data.IsDraft