🐛 Fix editing post got rejected
This commit is contained in:
parent
8cd7dca8aa
commit
1a3e43a12f
@ -179,13 +179,15 @@ func editArticle(c *fiber.Ctx) error {
|
||||
item.Categories = data.Categories
|
||||
item.IsDraft = data.IsDraft
|
||||
item.PublishedUntil = data.PublishedUntil
|
||||
item.PublishedAt = data.PublishedAt
|
||||
item.VisibleUsers = data.VisibleUsers
|
||||
item.InvisibleUsers = data.InvisibleUsers
|
||||
|
||||
// Preload publisher data
|
||||
item.Publisher = publisher
|
||||
|
||||
if item.PublishedAt == nil {
|
||||
item.PublishedAt = data.PublishedAt
|
||||
}
|
||||
if data.Visibility != nil {
|
||||
item.Visibility = *data.Visibility
|
||||
}
|
||||
|
@ -202,7 +202,6 @@ func editStory(c *fiber.Ctx) error {
|
||||
item.Tags = data.Tags
|
||||
item.Categories = data.Categories
|
||||
item.IsDraft = data.IsDraft
|
||||
item.PublishedAt = data.PublishedAt
|
||||
item.PublishedUntil = data.PublishedUntil
|
||||
item.VisibleUsers = data.VisibleUsers
|
||||
item.InvisibleUsers = data.InvisibleUsers
|
||||
@ -210,6 +209,9 @@ func editStory(c *fiber.Ctx) error {
|
||||
// Preload publisher data
|
||||
item.Publisher = publisher
|
||||
|
||||
if item.PublishedAt == nil {
|
||||
item.PublishedAt = data.PublishedAt
|
||||
}
|
||||
if data.Visibility != nil {
|
||||
item.Visibility = *data.Visibility
|
||||
}
|
||||
|
@ -460,9 +460,6 @@ func EditPost(item models.Post) (models.Post, error) {
|
||||
if item.Alias != nil && len(*item.Alias) == 0 {
|
||||
item.Alias = nil
|
||||
}
|
||||
if item.PublishedAt != nil && item.PublishedAt.UTC().Unix() < item.CreatedAt.UTC().Unix() {
|
||||
return item, fmt.Errorf("post cannot be published before it is created")
|
||||
}
|
||||
|
||||
if item.Alias != nil {
|
||||
re := regexp.MustCompile(`^[a-z0-9.-]+$`)
|
||||
|
Loading…
Reference in New Issue
Block a user