From fbe8e9b270df4e8e3c462b4a3f2573fa5f6dd5c4 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 29 Mar 2025 23:28:46 +0800 Subject: [PATCH] :bug: Fix scan attachments in ListPostV2 --- pkg/internal/services/queries/posts.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/internal/services/queries/posts.go b/pkg/internal/services/queries/posts.go index 03aafc8..aa19256 100644 --- a/pkg/internal/services/queries/posts.go +++ b/pkg/internal/services/queries/posts.go @@ -92,8 +92,13 @@ func ListPostV2(tx *gorm.DB, take int, offset int, order any, user *uint) ([]mod if info.Publisher.AccountID != nil { usersId = append(usersId, *info.Publisher.AccountID) } - if val, ok := info.Body["attachments"].([]string); ok && len(val) > 0 { - attachmentsRid = append(attachmentsRid, val...) + if raw, ok := info.Body["attachments"].([]any); ok && len(raw) > 0 { + attachmentsRid := make([]string, 0, len(raw)) + for _, v := range raw { + if str, ok := v.(string); ok { + attachmentsRid = append(attachmentsRid, str) + } + } } } log.Debug().Int("attachments", len(attachmentsRid)).Int("users", len(usersId)).Msg("Scanned metadata to load for listing post...")