⬆️ Use the latest version of paperclip
This commit is contained in:
parent
c656dc184a
commit
fe8c5d2821
@ -16,19 +16,19 @@ type PostReactInfo struct {
|
||||
type Post struct {
|
||||
BaseModel
|
||||
|
||||
Alias string `json:"alias" gorm:"uniqueIndex"`
|
||||
Content string `json:"content"`
|
||||
Tags []Tag `json:"tags" gorm:"many2many:post_tags"`
|
||||
Categories []Category `json:"categories" gorm:"many2many:post_categories"`
|
||||
Reactions []Reaction `json:"reactions"`
|
||||
Replies []Post `json:"replies" gorm:"foreignKey:ReplyID"`
|
||||
Attachments datatypes.JSONSlice[string] `json:"attachments"`
|
||||
ReplyID *uint `json:"reply_id"`
|
||||
RepostID *uint `json:"repost_id"`
|
||||
RealmID *uint `json:"realm_id"`
|
||||
ReplyTo *Post `json:"reply_to" gorm:"foreignKey:ReplyID"`
|
||||
RepostTo *Post `json:"repost_to" gorm:"foreignKey:RepostID"`
|
||||
Realm *Realm `json:"realm"`
|
||||
Alias string `json:"alias" gorm:"uniqueIndex"`
|
||||
Content string `json:"content"`
|
||||
Tags []Tag `json:"tags" gorm:"many2many:post_tags"`
|
||||
Categories []Category `json:"categories" gorm:"many2many:post_categories"`
|
||||
Reactions []Reaction `json:"reactions"`
|
||||
Replies []Post `json:"replies" gorm:"foreignKey:ReplyID"`
|
||||
Attachments datatypes.JSONSlice[uint] `json:"attachments"`
|
||||
ReplyID *uint `json:"reply_id"`
|
||||
RepostID *uint `json:"repost_id"`
|
||||
RealmID *uint `json:"realm_id"`
|
||||
ReplyTo *Post `json:"reply_to" gorm:"foreignKey:ReplyID"`
|
||||
RepostTo *Post `json:"repost_to" gorm:"foreignKey:RepostID"`
|
||||
Realm *Realm `json:"realm"`
|
||||
|
||||
PublishedAt *time.Time `json:"published_at"`
|
||||
|
||||
|
@ -80,7 +80,7 @@ func createPost(c *fiber.Ctx) error {
|
||||
Content string `json:"content" form:"content" validate:"required,max=4096"`
|
||||
Tags []models.Tag `json:"tags" form:"tags"`
|
||||
Categories []models.Category `json:"categories" form:"categories"`
|
||||
Attachments []string `json:"attachments" form:"attachments"`
|
||||
Attachments []uint `json:"attachments" form:"attachments"`
|
||||
PublishedAt *time.Time `json:"published_at" form:"published_at"`
|
||||
RealmAlias string `json:"realm" form:"realm"`
|
||||
ReplyTo *uint `json:"reply_to" form:"reply_to"`
|
||||
@ -94,7 +94,7 @@ func createPost(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
for _, attachment := range data.Attachments {
|
||||
if !services.CheckAttachmentByUUIDExists(attachment, "i.attachment") {
|
||||
if !services.CheckAttachmentByIDExists(attachment, "i.attachment") {
|
||||
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("attachment %s not found", attachment))
|
||||
}
|
||||
}
|
||||
@ -154,7 +154,7 @@ func editPost(c *fiber.Ctx) error {
|
||||
PublishedAt *time.Time `json:"published_at" form:"published_at"`
|
||||
Tags []models.Tag `json:"tags" form:"tags"`
|
||||
Categories []models.Category `json:"categories" form:"categories"`
|
||||
Attachments []string `json:"attachments" form:"attachments"`
|
||||
Attachments []uint `json:"attachments" form:"attachments"`
|
||||
}
|
||||
|
||||
if err := BindAndValidate(c, &data); err != nil {
|
||||
@ -170,7 +170,7 @@ func editPost(c *fiber.Ctx) error {
|
||||
}
|
||||
|
||||
for _, attachment := range data.Attachments {
|
||||
if !services.CheckAttachmentByUUIDExists(attachment, "i.attachment") {
|
||||
if !services.CheckAttachmentByIDExists(attachment, "i.attachment") {
|
||||
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("attachment %s not found", attachment))
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,9 @@ func GetAttachmentByUUID(uuid string) (*pcpb.Attachment, error) {
|
||||
})
|
||||
}
|
||||
|
||||
func CheckAttachmentByUUIDExists(uuid string, usage string) bool {
|
||||
func CheckAttachmentByIDExists(id uint, usage string) bool {
|
||||
_, err := grpc.Attachments.CheckAttachmentExists(context.Background(), &pcpb.AttachmentLookupRequest{
|
||||
Uuid: &uuid,
|
||||
Id: lo.ToPtr(uint64(id)),
|
||||
Usage: &usage,
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user