🐛 Fix edit draft state wont set published at
This commit is contained in:
parent
2f8f799926
commit
f49cd3a892
@ -2,6 +2,8 @@ package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.solsynth.dev/hydrogen/interactive/pkg/internal/database"
|
||||
"git.solsynth.dev/hydrogen/interactive/pkg/internal/gap"
|
||||
"git.solsynth.dev/hydrogen/interactive/pkg/internal/models"
|
||||
@ -9,7 +11,7 @@ import (
|
||||
"git.solsynth.dev/hydrogen/interactive/pkg/internal/services"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"time"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
func createArticle(c *fiber.Ctx) error {
|
||||
@ -107,6 +109,10 @@ func editArticle(c *fiber.Ctx) error {
|
||||
return fiber.NewError(fiber.StatusNotFound, err.Error())
|
||||
}
|
||||
|
||||
if item.IsDraft && !data.IsDraft {
|
||||
item.PublishedAt = lo.ToPtr(time.Now())
|
||||
}
|
||||
|
||||
body := models.PostArticleBody{
|
||||
Title: data.Title,
|
||||
Content: data.Content,
|
||||
|
@ -2,6 +2,8 @@ package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.solsynth.dev/hydrogen/interactive/pkg/internal/database"
|
||||
"git.solsynth.dev/hydrogen/interactive/pkg/internal/gap"
|
||||
"git.solsynth.dev/hydrogen/interactive/pkg/internal/models"
|
||||
@ -9,7 +11,7 @@ import (
|
||||
"git.solsynth.dev/hydrogen/interactive/pkg/internal/services"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"time"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
func createStory(c *fiber.Ctx) error {
|
||||
@ -126,6 +128,10 @@ func editStory(c *fiber.Ctx) error {
|
||||
return fiber.NewError(fiber.StatusNotFound, err.Error())
|
||||
}
|
||||
|
||||
if item.IsDraft && !data.IsDraft {
|
||||
item.PublishedAt = lo.ToPtr(time.Now())
|
||||
}
|
||||
|
||||
body := models.PostStoryBody{
|
||||
Title: data.Title,
|
||||
Content: data.Content,
|
||||
|
Loading…
Reference in New Issue
Block a user