🐛 Fix wrong way to determine own pack or not

This commit is contained in:
LittleSheep 2025-02-23 13:07:34 +08:00
parent 333aee6b45
commit 671b3fa5a3

View File

@ -3,6 +3,7 @@ package services
import (
"errors"
"fmt"
"gorm.io/gorm"
"git.solsynth.dev/hypernet/paperclip/pkg/internal/database"
@ -77,7 +78,7 @@ func DeleteSticker(sticker models.Sticker) (models.Sticker, error) {
func AddStickerPack(user uint, pack models.StickerPack) (models.StickerPackOwnership, error) {
var ownership models.StickerPackOwnership
if err := database.C.
Where("account_id = ?", user).
Where("account_id = ? AND pack_id = ?", user, pack.ID).
First(&ownership).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
return ownership, fmt.Errorf("unable to get current ownership: %v", err)
} else if err == nil {