🐛 Try to fix post has no published at
This commit is contained in:
parent
7ae1f8021b
commit
0519d99bbd
@ -65,6 +65,10 @@ func createArticle(c *fiber.Ctx) error {
|
||||
AuthorID: user.ID,
|
||||
}
|
||||
|
||||
if item.PublishedAt == nil {
|
||||
item.PublishedAt = lo.ToPtr(time.Now())
|
||||
}
|
||||
|
||||
if data.Visibility != nil {
|
||||
item.Visibility = *data.Visibility
|
||||
} else {
|
||||
|
@ -67,6 +67,10 @@ func createStory(c *fiber.Ctx) error {
|
||||
AuthorID: user.ID,
|
||||
}
|
||||
|
||||
if item.PublishedAt == nil {
|
||||
item.PublishedAt = lo.ToPtr(time.Now())
|
||||
}
|
||||
|
||||
if data.Visibility != nil {
|
||||
item.Visibility = *data.Visibility
|
||||
} else {
|
||||
|
@ -240,10 +240,6 @@ func NewPost(user models.Account, item models.Post) (models.Post, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if !item.IsDraft && item.PublishedAt == nil {
|
||||
item.PublishedAt = lo.ToPtr(time.Now())
|
||||
}
|
||||
|
||||
log.Debug().Msg("Saving post record into database...")
|
||||
if err := database.C.Save(&item).Error; err != nil {
|
||||
return item, err
|
||||
|
Loading…
Reference in New Issue
Block a user