From ec0444b35cef452614f3f44015af9ba5eda4a9b1 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 28 Dec 2024 23:12:19 +0800 Subject: [PATCH] :sparkles: Only can create boost on enabled destinations --- pkg/internal/services/boost.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/internal/services/boost.go b/pkg/internal/services/boost.go index 8e586cc..90e9210 100644 --- a/pkg/internal/services/boost.go +++ b/pkg/internal/services/boost.go @@ -1,6 +1,7 @@ package services import ( + "encoding/json" "fmt" "git.solsynth.dev/hypernet/nexus/pkg/nex/sec" @@ -63,9 +64,14 @@ func CreateBoost(user *sec.UserInfo, source models.Attachment, destination int) AccountID: user.ID, } - dests := cast.ToSlice(viper.Get("destinations")) - if destination >= len(dests) { + if des, ok := destinationsByIndex[destination]; !ok { return boost, fmt.Errorf("invalid destination: %d", destination) + } else { + var destBase models.BaseDestination + json.Unmarshal(des.Raw, &destBase) + if !destBase.IsBoost { + return boost, fmt.Errorf("invalid destination: %d; wasn't available for boost", destination) + } } if err := database.C.Create(&boost).Error; err != nil {