🐛 Trying to fix list post v2 didn't get the data

This commit is contained in:
LittleSheep 2025-03-29 23:00:55 +08:00
parent b2466bdee1
commit 9fe0962c4a
2 changed files with 4 additions and 3 deletions

View File

@ -30,6 +30,6 @@ type Publisher struct {
RealmID *uint `json:"realm_id"` RealmID *uint `json:"realm_id"`
AccountID *uint `json:"account_id"` AccountID *uint `json:"account_id"`
Account models.Account `gorm:"-"` Account models.Account `gorm:"-" json:"realm"`
Realm models.Realm `gorm:"-"` Realm models.Realm `gorm:"-" json:"realm"`
} }

View File

@ -111,7 +111,7 @@ func ListPostV2(tx *gorm.DB, take int, offset int, order any, user *uint) ([]mod
} }
// Putting information back to data // Putting information back to data
for _, item := range posts { for idx, item := range posts {
var this []fmodels.Attachment var this []fmodels.Attachment
if val, ok := item.Body["attachments"].([]string); ok && len(val) > 0 { if val, ok := item.Body["attachments"].([]string); ok && len(val) > 0 {
this = lo.Filter(attachments, func(item fmodels.Attachment, _ int) bool { this = lo.Filter(attachments, func(item fmodels.Attachment, _ int) bool {
@ -125,6 +125,7 @@ func ListPostV2(tx *gorm.DB, take int, offset int, order any, user *uint) ([]mod
} }
return acc.ID == *item.Publisher.AccountID return acc.ID == *item.Publisher.AccountID
}) })
posts[idx] = item
} }
// Add post views for the user // Add post views for the user