Compare commits

..

No commits in common. "78e554577ed4e7aaac309b339e57c09de63b8c62" and "c6944cd3df5ef4aadb284f4aa1fbe9f1e74c6132" have entirely different histories.

2 changed files with 3 additions and 17 deletions
pkg/internal/services

@ -44,16 +44,6 @@ 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.
@ -66,12 +56,7 @@ func GetBoostByID(id uint) (models.AttachmentBoost, error) {
}
func CreateBoost(user *sec.UserInfo, source models.Attachment, destination int) (models.AttachmentBoost, error) {
var boost models.AttachmentBoost
if err := database.C.Where("attachment_id = ? AND destination = ?", source.ID, destination).First(&boost); err == nil {
return boost, fmt.Errorf("boost already exists")
}
boost = models.AttachmentBoost{
boost := models.AttachmentBoost{
Status: models.BoostStatusPending,
Destination: destination,
AttachmentID: source.ID,

@ -52,12 +52,13 @@ 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 = ListBoostByAttachmentWithStatus(attachment.ID, models.BoostStatusActive)
boosts, err = ListBoostByAttachment(attachment.ID)
if err != nil {
return
}