👔 Update the edited at detection logic

This commit is contained in:
LittleSheep 2024-07-30 12:31:33 +08:00
parent f19de97e8e
commit 830484fee1
3 changed files with 8 additions and 1 deletions

View File

@ -131,6 +131,10 @@ func editArticle(c *fiber.Ctx) error {
return fiber.NewError(fiber.StatusForbidden, "post was locked")
}
if !item.IsDraft && !data.IsDraft {
item.EditedAt = lo.ToPtr(time.Now())
}
if item.IsDraft && !data.IsDraft && data.PublishedAt == nil {
item.PublishedAt = lo.ToPtr(time.Now())
} else {

View File

@ -150,6 +150,10 @@ func editStory(c *fiber.Ctx) error {
return fiber.NewError(fiber.StatusForbidden, "post was locked")
}
if !item.IsDraft && !data.IsDraft {
item.EditedAt = lo.ToPtr(time.Now())
}
if item.IsDraft && !data.IsDraft && data.PublishedAt == nil {
item.PublishedAt = lo.ToPtr(time.Now())
} else {

View File

@ -280,7 +280,6 @@ func NewPost(user models.Account, item models.Post) (models.Post, error) {
}
func EditPost(item models.Post) (models.Post, error) {
item.EditedAt = lo.ToPtr(time.Now())
item, err := EnsurePostCategoriesAndTags(item)
if err != nil {
return item, err