From a77981f0a6169ad8fa04bba0b3d6a7eeb32a49b3 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 18 Feb 2024 03:21:52 -0500 Subject: [PATCH] fix: PinByHash does not query right --- account/account.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/account/account.go b/account/account.go index 92c457a..8bbb1e0 100644 --- a/account/account.go +++ b/account/account.go @@ -284,18 +284,16 @@ func (s AccountServiceDefault) PinByHash(hash []byte, userId uint) error { // Define a struct for the query condition uploadQuery := models.Upload{Hash: hash} - // Retrieve the upload ID for the given hash - var uploadID uint result := s.db. - Model(&models.Upload{}). + Model(&uploadQuery). Where(&uploadQuery). - First(&uploadID) + First(&uploadQuery) if result.Error != nil { return result.Error } - return s.PinByID(uploadID, userId) + return s.PinByID(uploadQuery.ID, userId) } func (s AccountServiceDefault) PinByID(uploadId uint, userId uint) error {