fix: PinByHash does not query right

This commit is contained in:
Derrick Hammer 2024-02-18 03:21:52 -05:00
parent ae7d048e6c
commit a77981f0a6
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 3 additions and 5 deletions

View File

@ -284,18 +284,16 @@ func (s AccountServiceDefault) PinByHash(hash []byte, userId uint) error {
// Define a struct for the query condition // Define a struct for the query condition
uploadQuery := models.Upload{Hash: hash} uploadQuery := models.Upload{Hash: hash}
// Retrieve the upload ID for the given hash
var uploadID uint
result := s.db. result := s.db.
Model(&models.Upload{}). Model(&uploadQuery).
Where(&uploadQuery). Where(&uploadQuery).
First(&uploadID) First(&uploadQuery)
if result.Error != nil { if result.Error != nil {
return result.Error return result.Error
} }
return s.PinByID(uploadID, userId) return s.PinByID(uploadQuery.ID, userId)
} }
func (s AccountServiceDefault) PinByID(uploadId uint, userId uint) error { func (s AccountServiceDefault) PinByID(uploadId uint, userId uint) error {