🐛 Fix attachments in body issue
This commit is contained in:
@ -121,7 +121,15 @@ func ListPostV2(tx *gorm.DB, take int, offset int, order any, user *uint) ([]mod
|
||||
log.Info().Int("attachments", len(attachments)).Int("users", len(users)).Msg("Batch loaded metadata for listing post...")
|
||||
for idx, item := range posts {
|
||||
var this []fmodels.Attachment
|
||||
if val, ok := item.Body["attachments"].([]string); ok && len(val) > 0 {
|
||||
var val []string
|
||||
if raw, ok := item.Body["attachments"].([]any); ok && len(raw) > 0 {
|
||||
val = lo.Map(raw, func(v any, _ int) string {
|
||||
return v.(string) // Safe if you're sure all elements are strings
|
||||
})
|
||||
} else if raw, ok := item.Body["attachments"].([]string); ok {
|
||||
val = raw
|
||||
}
|
||||
if len(val) > 0 {
|
||||
this = lo.Filter(attachments, func(item fmodels.Attachment, _ int) bool {
|
||||
return lo.Contains(val, item.Rid)
|
||||
})
|
||||
|
Reference in New Issue
Block a user