🐛 Bug fixes of edit comment
✨ Comments now supports attachment!
This commit is contained in:
parent
82a6c6dd31
commit
1181b1e5ce
@ -3,12 +3,13 @@ package models
|
|||||||
type Comment struct {
|
type Comment struct {
|
||||||
PostBase
|
PostBase
|
||||||
|
|
||||||
Content string `json:"content"`
|
Content string `json:"content"`
|
||||||
Hashtags []Tag `json:"tags" gorm:"many2many:comment_tags"`
|
Hashtags []Tag `json:"tags" gorm:"many2many:comment_tags"`
|
||||||
Categories []Category `json:"categories" gorm:"many2many:comment_categories"`
|
Categories []Category `json:"categories" gorm:"many2many:comment_categories"`
|
||||||
Reactions []Reaction `json:"reactions"`
|
Reactions []Reaction `json:"reactions"`
|
||||||
ReplyID *uint `json:"reply_id"`
|
Attachments []Attachment `json:"attachments"`
|
||||||
ReplyTo *Comment `json:"reply_to" gorm:"foreignKey:ReplyID"`
|
ReplyID *uint `json:"reply_id"`
|
||||||
|
ReplyTo *Comment `json:"reply_to" gorm:"foreignKey:ReplyID"`
|
||||||
|
|
||||||
ArticleID *uint `json:"article_id"`
|
ArticleID *uint `json:"article_id"`
|
||||||
MomentID *uint `json:"moment_id"`
|
MomentID *uint `json:"moment_id"`
|
||||||
|
@ -57,11 +57,12 @@ func createComment(c *fiber.Ctx) error {
|
|||||||
user := c.Locals("principal").(models.Account)
|
user := c.Locals("principal").(models.Account)
|
||||||
|
|
||||||
var data struct {
|
var data struct {
|
||||||
Content string `json:"content" form:"content" validate:"required"`
|
Content string `json:"content" form:"content" validate:"required"`
|
||||||
PublishedAt *time.Time `json:"published_at" form:"published_at"`
|
PublishedAt *time.Time `json:"published_at" form:"published_at"`
|
||||||
Hashtags []models.Tag `json:"hashtags" form:"hashtags"`
|
Hashtags []models.Tag `json:"hashtags" form:"hashtags"`
|
||||||
Categories []models.Category `json:"categories" form:"categories"`
|
Categories []models.Category `json:"categories" form:"categories"`
|
||||||
ReplyTo uint `json:"reply_to" form:"reply_to"`
|
Attachments []models.Attachment `json:"attachments" form:"attachments"`
|
||||||
|
ReplyTo uint `json:"reply_to" form:"reply_to"`
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := BindAndValidate(c, &data); err != nil {
|
if err := BindAndValidate(c, &data); err != nil {
|
||||||
@ -74,9 +75,10 @@ func createComment(c *fiber.Ctx) error {
|
|||||||
PublishedAt: data.PublishedAt,
|
PublishedAt: data.PublishedAt,
|
||||||
AuthorID: user.ID,
|
AuthorID: user.ID,
|
||||||
},
|
},
|
||||||
Hashtags: data.Hashtags,
|
Hashtags: data.Hashtags,
|
||||||
Categories: data.Categories,
|
Categories: data.Categories,
|
||||||
Content: data.Content,
|
Attachments: data.Attachments,
|
||||||
|
Content: data.Content,
|
||||||
}
|
}
|
||||||
|
|
||||||
postType := c.Params("postType")
|
postType := c.Params("postType")
|
||||||
|
@ -100,7 +100,7 @@ func editMoment(c *fiber.Ctx) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var item *models.Moment
|
var item *models.Comment
|
||||||
if err := database.C.Where(models.Comment{
|
if err := database.C.Where(models.Comment{
|
||||||
PostBase: models.PostBase{
|
PostBase: models.PostBase{
|
||||||
BaseModel: models.BaseModel{ID: uint(id)},
|
BaseModel: models.BaseModel{ID: uint(id)},
|
||||||
|
Loading…
Reference in New Issue
Block a user