diff --git a/pkg/internal/services/boost.go b/pkg/internal/services/boost.go index a94b9cd..c76297e 100644 --- a/pkg/internal/services/boost.go +++ b/pkg/internal/services/boost.go @@ -44,6 +44,16 @@ func ListBoostByAttachment(attachmentId uint) ([]models.AttachmentBoost, error) return boosts, nil } +func ListBoostByAttachmentWithStatus(attachmentId uint, status int) ([]models.AttachmentBoost, error) { + var boosts []models.AttachmentBoost + if err := database.C. + Where("attachment_id = ? AND status = ?", attachmentId, status). + Find(&boosts).Error; err != nil { + return boosts, err + } + return boosts, nil +} + func GetBoostByID(id uint) (models.AttachmentBoost, error) { var boost models.AttachmentBoost if err := database.C. diff --git a/pkg/internal/services/opener.go b/pkg/internal/services/opener.go index 1742b36..a3b16ea 100644 --- a/pkg/internal/services/opener.go +++ b/pkg/internal/services/opener.go @@ -52,13 +52,12 @@ func OpenAttachmentByRID(rid string, region ...string) (url string, mimetype str Preload("Pool"). Preload("Thumbnail"). Preload("Compressed"). - Preload("Boosts"). First(&attachment).Error; err != nil { return } var boosts []models.AttachmentBoost - boosts, err = ListBoostByAttachment(attachment.ID) + boosts, err = ListBoostByAttachmentWithStatus(attachment.ID, models.BoostStatusActive) if err != nil { return }