From 8070a87078e0a28346a08dcb30c739bb08b629cc Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 3 Aug 2024 03:22:45 +0800 Subject: [PATCH] :bug: Fix attachment meta dir to prevent further bugs --- pkg/internal/server/api/attachment_dir_api.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/internal/server/api/attachment_dir_api.go b/pkg/internal/server/api/attachment_dir_api.go index 20e9139..290cb54 100644 --- a/pkg/internal/server/api/attachment_dir_api.go +++ b/pkg/internal/server/api/attachment_dir_api.go @@ -16,10 +16,14 @@ func listAttachment(c *fiber.Ctx) error { take = 100 } - tx := database.C.Order("created_at DESC") + tx := database.C if len(c.Query("id")) > 0 { tx = tx.Where("id IN ?", strings.Split(c.Query("id"), ",")) + } else { + // Do sort this when doesn't filter by the id + // Because the sort will mess up the result + tx = tx.Order("created_at DESC") } if len(c.Query("author")) > 0 {