♿ Edit post will auto help user correct data
This commit is contained in:
parent
f49cd3a892
commit
c8d55d0b2c
@ -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 {
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user