♿ 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())
|
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())
|
item.PublishedAt = lo.ToPtr(time.Now())
|
||||||
|
} else {
|
||||||
|
item.PublishedAt = data.PublishedAt
|
||||||
}
|
}
|
||||||
|
|
||||||
body := models.PostArticleBody{
|
body := models.PostArticleBody{
|
||||||
@ -128,7 +130,6 @@ func editArticle(c *fiber.Ctx) error {
|
|||||||
item.Tags = data.Tags
|
item.Tags = data.Tags
|
||||||
item.Categories = data.Categories
|
item.Categories = data.Categories
|
||||||
item.IsDraft = data.IsDraft
|
item.IsDraft = data.IsDraft
|
||||||
item.PublishedAt = data.PublishedAt
|
|
||||||
item.PublishedUntil = data.PublishedUntil
|
item.PublishedUntil = data.PublishedUntil
|
||||||
|
|
||||||
if item, err := services.EditPost(item); err != nil {
|
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())
|
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())
|
item.PublishedAt = lo.ToPtr(time.Now())
|
||||||
|
} else {
|
||||||
|
item.PublishedAt = data.PublishedAt
|
||||||
}
|
}
|
||||||
|
|
||||||
body := models.PostStoryBody{
|
body := models.PostStoryBody{
|
||||||
@ -147,7 +149,6 @@ func editStory(c *fiber.Ctx) error {
|
|||||||
item.Language = services.DetectLanguage(data.Content)
|
item.Language = services.DetectLanguage(data.Content)
|
||||||
item.Tags = data.Tags
|
item.Tags = data.Tags
|
||||||
item.Categories = data.Categories
|
item.Categories = data.Categories
|
||||||
item.PublishedAt = data.PublishedAt
|
|
||||||
item.PublishedUntil = data.PublishedUntil
|
item.PublishedUntil = data.PublishedUntil
|
||||||
item.IsDraft = data.IsDraft
|
item.IsDraft = data.IsDraft
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user