⬆️ Use the latest version of paperclip
This commit is contained in:
		| @@ -22,7 +22,7 @@ type Post struct { | |||||||
| 	Categories  []Category                `json:"categories" gorm:"many2many:post_categories"` | 	Categories  []Category                `json:"categories" gorm:"many2many:post_categories"` | ||||||
| 	Reactions   []Reaction                `json:"reactions"` | 	Reactions   []Reaction                `json:"reactions"` | ||||||
| 	Replies     []Post                    `json:"replies" gorm:"foreignKey:ReplyID"` | 	Replies     []Post                    `json:"replies" gorm:"foreignKey:ReplyID"` | ||||||
| 	Attachments datatypes.JSONSlice[string] `json:"attachments"` | 	Attachments datatypes.JSONSlice[uint] `json:"attachments"` | ||||||
| 	ReplyID     *uint                     `json:"reply_id"` | 	ReplyID     *uint                     `json:"reply_id"` | ||||||
| 	RepostID    *uint                     `json:"repost_id"` | 	RepostID    *uint                     `json:"repost_id"` | ||||||
| 	RealmID     *uint                     `json:"realm_id"` | 	RealmID     *uint                     `json:"realm_id"` | ||||||
|   | |||||||
| @@ -80,7 +80,7 @@ func createPost(c *fiber.Ctx) error { | |||||||
| 		Content     string            `json:"content" form:"content" validate:"required,max=4096"` | 		Content     string            `json:"content" form:"content" validate:"required,max=4096"` | ||||||
| 		Tags        []models.Tag      `json:"tags" form:"tags"` | 		Tags        []models.Tag      `json:"tags" form:"tags"` | ||||||
| 		Categories  []models.Category `json:"categories" form:"categories"` | 		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"` | 		PublishedAt *time.Time        `json:"published_at" form:"published_at"` | ||||||
| 		RealmAlias  string            `json:"realm" form:"realm"` | 		RealmAlias  string            `json:"realm" form:"realm"` | ||||||
| 		ReplyTo     *uint             `json:"reply_to" form:"reply_to"` | 		ReplyTo     *uint             `json:"reply_to" form:"reply_to"` | ||||||
| @@ -94,7 +94,7 @@ func createPost(c *fiber.Ctx) error { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	for _, attachment := range data.Attachments { | 	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)) | 			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"` | 		PublishedAt *time.Time        `json:"published_at" form:"published_at"` | ||||||
| 		Tags        []models.Tag      `json:"tags" form:"tags"` | 		Tags        []models.Tag      `json:"tags" form:"tags"` | ||||||
| 		Categories  []models.Category `json:"categories" form:"categories"` | 		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 { | 	if err := BindAndValidate(c, &data); err != nil { | ||||||
| @@ -170,7 +170,7 @@ func editPost(c *fiber.Ctx) error { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	for _, attachment := range data.Attachments { | 	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)) | 			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{ | 	_, err := grpc.Attachments.CheckAttachmentExists(context.Background(), &pcpb.AttachmentLookupRequest{ | ||||||
| 		Uuid:  &uuid, | 		Id:    lo.ToPtr(uint64(id)), | ||||||
| 		Usage: &usage, | 		Usage: &usage, | ||||||
| 	}) | 	}) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user