⬆️ Use faster way to check attachment it exists

This commit is contained in:
2024-05-18 16:59:58 +08:00
parent 827423ae3f
commit 7d36755a72
6 changed files with 17 additions and 15 deletions

View File

@@ -94,8 +94,8 @@ func createPost(c *fiber.Ctx) error {
}
for _, attachment := range data.Attachments {
if _, err := services.GetAttachmentByUUID(attachment); err != nil {
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("attachment %s not found: %v", attachment, err))
if services.CheckAttachmentByUUIDExists(attachment, "i.attachment") {
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("attachment %s not found", attachment))
}
}
@@ -170,8 +170,8 @@ func editPost(c *fiber.Ctx) error {
}
for _, attachment := range data.Attachments {
if _, err := services.GetAttachmentByUUID(attachment); err != nil {
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("attachment %s not found: %v", attachment, err))
if services.CheckAttachmentByUUIDExists(attachment, "i.attachment") {
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("attachment %s not found", attachment))
}
}