👔 Allow post only with attachments
🐛 Fix thumbnail issue
This commit is contained in:
parent
08ba9ae758
commit
bca0f9025c
@ -30,7 +30,7 @@ func createArticle(c *fiber.Ctx) error {
|
|||||||
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"`
|
||||||
Thumbnail string `json:"thumbnail"`
|
Thumbnail *string `json:"thumbnail"`
|
||||||
Attachments []string `json:"attachments"`
|
Attachments []string `json:"attachments"`
|
||||||
Tags []models.Tag `json:"tags"`
|
Tags []models.Tag `json:"tags"`
|
||||||
Categories []models.Category `json:"categories"`
|
Categories []models.Category `json:"categories"`
|
||||||
@ -116,7 +116,7 @@ func editArticle(c *fiber.Ctx) error {
|
|||||||
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"`
|
||||||
Thumbnail string `json:"thumbnail"`
|
Thumbnail *string `json:"thumbnail"`
|
||||||
Attachments []string `json:"attachments"`
|
Attachments []string `json:"attachments"`
|
||||||
Tags []models.Tag `json:"tags"`
|
Tags []models.Tag `json:"tags"`
|
||||||
Categories []models.Category `json:"categories"`
|
Categories []models.Category `json:"categories"`
|
||||||
|
@ -29,9 +29,9 @@ func createStory(c *fiber.Ctx) error {
|
|||||||
Publisher uint `json:"publisher"`
|
Publisher uint `json:"publisher"`
|
||||||
Alias *string `json:"alias"`
|
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:"max=4096"`
|
||||||
Location *string `json:"location"`
|
Location *string `json:"location"`
|
||||||
Thumbnail string `json:"thumbnail"`
|
Thumbnail *string `json:"thumbnail"`
|
||||||
Attachments []string `json:"attachments"`
|
Attachments []string `json:"attachments"`
|
||||||
Tags []models.Tag `json:"tags"`
|
Tags []models.Tag `json:"tags"`
|
||||||
Categories []models.Category `json:"categories"`
|
Categories []models.Category `json:"categories"`
|
||||||
@ -47,6 +47,8 @@ func createStory(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
if err := exts.BindAndValidate(c, &data); err != nil {
|
if err := exts.BindAndValidate(c, &data); err != nil {
|
||||||
return err
|
return err
|
||||||
|
} else if len(data.Content) == 0 && len(data.Attachments) == 0 {
|
||||||
|
return fiber.NewError(fiber.StatusBadRequest, "content or attachments are required")
|
||||||
}
|
}
|
||||||
|
|
||||||
publisher, err := services.GetPublisher(data.Publisher, user.ID)
|
publisher, err := services.GetPublisher(data.Publisher, user.ID)
|
||||||
@ -134,8 +136,8 @@ func editStory(c *fiber.Ctx) error {
|
|||||||
Publisher uint `json:"publisher"`
|
Publisher uint `json:"publisher"`
|
||||||
Alias *string `json:"alias"`
|
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:"max=4096"`
|
||||||
Thumbnail string `json:"thumbnail"`
|
Thumbnail *string `json:"thumbnail"`
|
||||||
Location *string `json:"location"`
|
Location *string `json:"location"`
|
||||||
Attachments []string `json:"attachments"`
|
Attachments []string `json:"attachments"`
|
||||||
Tags []models.Tag `json:"tags"`
|
Tags []models.Tag `json:"tags"`
|
||||||
@ -150,6 +152,8 @@ func editStory(c *fiber.Ctx) error {
|
|||||||
|
|
||||||
if err := exts.BindAndValidate(c, &data); err != nil {
|
if err := exts.BindAndValidate(c, &data); err != nil {
|
||||||
return err
|
return err
|
||||||
|
} else if len(data.Content) == 0 && len(data.Attachments) == 0 {
|
||||||
|
return fiber.NewError(fiber.StatusBadRequest, "content or attachments are required")
|
||||||
}
|
}
|
||||||
|
|
||||||
publisher, err := services.GetPublisher(data.Publisher, user.ID)
|
publisher, err := services.GetPublisher(data.Publisher, user.ID)
|
||||||
|
@ -65,7 +65,7 @@ type Post struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PostStoryBody struct {
|
type PostStoryBody struct {
|
||||||
Thumbnail string `json:"thumbnail"`
|
Thumbnail *string `json:"thumbnail"`
|
||||||
Title *string `json:"title"`
|
Title *string `json:"title"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
Location *string `json:"location"`
|
Location *string `json:"location"`
|
||||||
@ -73,7 +73,7 @@ type PostStoryBody struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PostArticleBody struct {
|
type PostArticleBody struct {
|
||||||
Thumbnail string `json:"thumbnail"`
|
Thumbnail *string `json:"thumbnail"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Description *string `json:"description"`
|
Description *string `json:"description"`
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
|
Loading…
Reference in New Issue
Block a user