diff --git a/pkg/internal/models/posts.go b/pkg/internal/models/posts.go index 8b43b20..7192dc3 100644 --- a/pkg/internal/models/posts.go +++ b/pkg/internal/models/posts.go @@ -27,6 +27,7 @@ type Post struct { Type string `json:"type"` Body datatypes.JSONMap `json:"body"` Language string `json:"language"` + Alias *string `json:"alias"` Tags []Tag `json:"tags" gorm:"many2many:post_tags"` Categories []Category `json:"categories" gorm:"many2many:post_categories"` Reactions []Reaction `json:"reactions"` diff --git a/pkg/internal/server/api/articles_api.go b/pkg/internal/server/api/articles_api.go index d551505..8a4a638 100644 --- a/pkg/internal/server/api/articles_api.go +++ b/pkg/internal/server/api/articles_api.go @@ -21,6 +21,7 @@ func createArticle(c *fiber.Ctx) error { user := c.Locals("user").(models.Account) var data struct { + Alias *string `json:"alias"` Title string `json:"title" validate:"required,max=1024"` Description *string `json:"description"` Content string `json:"content" validate:"required"` @@ -54,6 +55,7 @@ func createArticle(c *fiber.Ctx) error { _ = jsoniter.Unmarshal(rawBody, &bodyMapping) item := models.Post{ + Alias: data.Alias, Type: models.PostTypeArticle, Body: bodyMapping, Language: services.DetectLanguage(data.Content), @@ -103,6 +105,7 @@ func editArticle(c *fiber.Ctx) error { user := c.Locals("user").(models.Account) var data struct { + Alias *string `json:"alias"` Title string `json:"title" validate:"required,max=1024"` Description *string `json:"description"` Content string `json:"content" validate:"required"` @@ -157,6 +160,7 @@ func editArticle(c *fiber.Ctx) error { rawBody, _ := jsoniter.Marshal(body) _ = jsoniter.Unmarshal(rawBody, &bodyMapping) + item.Alias = data.Alias item.Body = bodyMapping item.Language = services.DetectLanguage(data.Content) item.Tags = data.Tags diff --git a/pkg/internal/server/api/stories_api.go b/pkg/internal/server/api/stories_api.go index 215e327..c4dddc6 100644 --- a/pkg/internal/server/api/stories_api.go +++ b/pkg/internal/server/api/stories_api.go @@ -21,6 +21,7 @@ func createStory(c *fiber.Ctx) error { user := c.Locals("user").(models.Account) var data struct { + Alias *string `json:"alias"` Title *string `json:"title"` Content string `json:"content" validate:"required,max=4096"` Location *string `json:"location"` @@ -56,6 +57,7 @@ func createStory(c *fiber.Ctx) error { _ = jsoniter.Unmarshal(rawBody, &bodyMapping) item := models.Post{ + Alias: data.Alias, Type: models.PostTypeStory, Body: bodyMapping, Language: services.DetectLanguage(data.Content), @@ -122,6 +124,7 @@ func editStory(c *fiber.Ctx) error { user := c.Locals("user").(models.Account) var data struct { + Alias *string `json:"alias"` Title *string `json:"title"` Content string `json:"content" validate:"required,max=4096"` Thumbnail *uint `json:"thumbnail"` @@ -176,6 +179,7 @@ func editStory(c *fiber.Ctx) error { rawBody, _ := jsoniter.Marshal(body) _ = jsoniter.Unmarshal(rawBody, &bodyMapping) + item.Alias = data.Alias item.Body = bodyMapping item.Language = services.DetectLanguage(data.Content) item.Tags = data.Tags