⏪ Alias is back
This commit is contained in:
		| @@ -27,6 +27,7 @@ type Post struct { | |||||||
| 	Type       string            `json:"type"` | 	Type       string            `json:"type"` | ||||||
| 	Body       datatypes.JSONMap `json:"body"` | 	Body       datatypes.JSONMap `json:"body"` | ||||||
| 	Language   string            `json:"language"` | 	Language   string            `json:"language"` | ||||||
|  | 	Alias      *string           `json:"alias"` | ||||||
| 	Tags       []Tag             `json:"tags" gorm:"many2many:post_tags"` | 	Tags       []Tag             `json:"tags" gorm:"many2many:post_tags"` | ||||||
| 	Categories []Category        `json:"categories" gorm:"many2many:post_categories"` | 	Categories []Category        `json:"categories" gorm:"many2many:post_categories"` | ||||||
| 	Reactions  []Reaction        `json:"reactions"` | 	Reactions  []Reaction        `json:"reactions"` | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ func createArticle(c *fiber.Ctx) error { | |||||||
| 	user := c.Locals("user").(models.Account) | 	user := c.Locals("user").(models.Account) | ||||||
|  |  | ||||||
| 	var data struct { | 	var data struct { | ||||||
|  | 		Alias          *string           `json:"alias"` | ||||||
| 		Title          string            `json:"title" validate:"required,max=1024"` | 		Title          string            `json:"title" validate:"required,max=1024"` | ||||||
| 		Description    *string           `json:"description"` | 		Description    *string           `json:"description"` | ||||||
| 		Content        string            `json:"content" validate:"required"` | 		Content        string            `json:"content" validate:"required"` | ||||||
| @@ -54,6 +55,7 @@ func createArticle(c *fiber.Ctx) error { | |||||||
| 	_ = jsoniter.Unmarshal(rawBody, &bodyMapping) | 	_ = jsoniter.Unmarshal(rawBody, &bodyMapping) | ||||||
|  |  | ||||||
| 	item := models.Post{ | 	item := models.Post{ | ||||||
|  | 		Alias:          data.Alias, | ||||||
| 		Type:           models.PostTypeArticle, | 		Type:           models.PostTypeArticle, | ||||||
| 		Body:           bodyMapping, | 		Body:           bodyMapping, | ||||||
| 		Language:       services.DetectLanguage(data.Content), | 		Language:       services.DetectLanguage(data.Content), | ||||||
| @@ -103,6 +105,7 @@ func editArticle(c *fiber.Ctx) error { | |||||||
| 	user := c.Locals("user").(models.Account) | 	user := c.Locals("user").(models.Account) | ||||||
|  |  | ||||||
| 	var data struct { | 	var data struct { | ||||||
|  | 		Alias          *string           `json:"alias"` | ||||||
| 		Title          string            `json:"title" validate:"required,max=1024"` | 		Title          string            `json:"title" validate:"required,max=1024"` | ||||||
| 		Description    *string           `json:"description"` | 		Description    *string           `json:"description"` | ||||||
| 		Content        string            `json:"content" validate:"required"` | 		Content        string            `json:"content" validate:"required"` | ||||||
| @@ -157,6 +160,7 @@ func editArticle(c *fiber.Ctx) error { | |||||||
| 	rawBody, _ := jsoniter.Marshal(body) | 	rawBody, _ := jsoniter.Marshal(body) | ||||||
| 	_ = jsoniter.Unmarshal(rawBody, &bodyMapping) | 	_ = jsoniter.Unmarshal(rawBody, &bodyMapping) | ||||||
|  |  | ||||||
|  | 	item.Alias = data.Alias | ||||||
| 	item.Body = bodyMapping | 	item.Body = bodyMapping | ||||||
| 	item.Language = services.DetectLanguage(data.Content) | 	item.Language = services.DetectLanguage(data.Content) | ||||||
| 	item.Tags = data.Tags | 	item.Tags = data.Tags | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ func createStory(c *fiber.Ctx) error { | |||||||
| 	user := c.Locals("user").(models.Account) | 	user := c.Locals("user").(models.Account) | ||||||
|  |  | ||||||
| 	var data struct { | 	var data struct { | ||||||
|  | 		Alias          *string           `json:"alias"` | ||||||
| 		Title          *string           `json:"title"` | 		Title          *string           `json:"title"` | ||||||
| 		Content        string            `json:"content" validate:"required,max=4096"` | 		Content        string            `json:"content" validate:"required,max=4096"` | ||||||
| 		Location       *string           `json:"location"` | 		Location       *string           `json:"location"` | ||||||
| @@ -56,6 +57,7 @@ func createStory(c *fiber.Ctx) error { | |||||||
| 	_ = jsoniter.Unmarshal(rawBody, &bodyMapping) | 	_ = jsoniter.Unmarshal(rawBody, &bodyMapping) | ||||||
|  |  | ||||||
| 	item := models.Post{ | 	item := models.Post{ | ||||||
|  | 		Alias:          data.Alias, | ||||||
| 		Type:           models.PostTypeStory, | 		Type:           models.PostTypeStory, | ||||||
| 		Body:           bodyMapping, | 		Body:           bodyMapping, | ||||||
| 		Language:       services.DetectLanguage(data.Content), | 		Language:       services.DetectLanguage(data.Content), | ||||||
| @@ -122,6 +124,7 @@ func editStory(c *fiber.Ctx) error { | |||||||
| 	user := c.Locals("user").(models.Account) | 	user := c.Locals("user").(models.Account) | ||||||
|  |  | ||||||
| 	var data struct { | 	var data struct { | ||||||
|  | 		Alias          *string           `json:"alias"` | ||||||
| 		Title          *string           `json:"title"` | 		Title          *string           `json:"title"` | ||||||
| 		Content        string            `json:"content" validate:"required,max=4096"` | 		Content        string            `json:"content" validate:"required,max=4096"` | ||||||
| 		Thumbnail      *uint             `json:"thumbnail"` | 		Thumbnail      *uint             `json:"thumbnail"` | ||||||
| @@ -176,6 +179,7 @@ func editStory(c *fiber.Ctx) error { | |||||||
| 	rawBody, _ := jsoniter.Marshal(body) | 	rawBody, _ := jsoniter.Marshal(body) | ||||||
| 	_ = jsoniter.Unmarshal(rawBody, &bodyMapping) | 	_ = jsoniter.Unmarshal(rawBody, &bodyMapping) | ||||||
|  |  | ||||||
|  | 	item.Alias = data.Alias | ||||||
| 	item.Body = bodyMapping | 	item.Body = bodyMapping | ||||||
| 	item.Language = services.DetectLanguage(data.Content) | 	item.Language = services.DetectLanguage(data.Content) | ||||||
| 	item.Tags = data.Tags | 	item.Tags = data.Tags | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user