diff --git a/cmd/gotosocial/action/server/server.go b/cmd/gotosocial/action/server/server.go index bafb23a40..0845e5ed1 100644 --- a/cmd/gotosocial/action/server/server.go +++ b/cmd/gotosocial/action/server/server.go @@ -499,7 +499,7 @@ var Start action.GTSAction = func(ctx context.Context) error { s2sLimit := middleware.RateLimit(rlLimit, exceptions) // server-to-server (AP) fsMainLimit := middleware.RateLimit(rlLimit, exceptions) // fileserver / web templates fsEmojiLimit := middleware.RateLimit(rlLimit*2, exceptions) // fileserver (emojis only, use high limit) - nollamas := middleware.NoLLaMas(state.DB) + nollamas := middleware.NoLLaMas(instanceAccount) // throttling cpuMultiplier := config.GetAdvancedThrottlingMultiplier() diff --git a/cmd/gotosocial/action/testrig/testrig.go b/cmd/gotosocial/action/testrig/testrig.go index e3a764790..cca4ead22 100644 --- a/cmd/gotosocial/action/testrig/testrig.go +++ b/cmd/gotosocial/action/testrig/testrig.go @@ -257,8 +257,6 @@ var Start action.GTSAction = func(ctx context.Context) error { nodeInfoModule = api.NewNodeInfo(processor) // nodeinfo endpoint activityPubModule = api.NewActivityPub(state.DB, processor) // ActivityPub endpoints webModule = web.New(state.DB, processor) // web pages + user profiles + settings panels etc - - nollamas = middleware.NoLLaMas(state.DB) ) // these should be routed in order @@ -273,7 +271,7 @@ var Start action.GTSAction = func(ctx context.Context) error { nodeInfoModule.Route(route) activityPubModule.Route(route) activityPubModule.RoutePublicKey(route) - webModule.Route(route, nollamas) + webModule.Route(route) // Create background cleaner. cleaner := cleaner.New(state) diff --git a/internal/middleware/nollamas.go b/internal/middleware/nollamas.go index 6728e2b7b..f2544c1ff 100644 --- a/internal/middleware/nollamas.go +++ b/internal/middleware/nollamas.go @@ -18,7 +18,6 @@ package middleware import ( - "context" "crypto/sha256" "crypto/sha512" "crypto/subtle" @@ -30,19 +29,14 @@ import ( "codeberg.org/gruf/go-byteutil" "github.com/gin-gonic/gin" - "github.com/superseriousbusiness/gotosocial/internal/db" + "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/oauth" ) -func NoLLaMas(db db.DB) gin.HandlerFunc { - instance, err := db.GetInstanceAccount(context.Background(), "") - if err != nil { - panic(err) - } - +func NoLLaMas(instanceAcc *gtsmodel.Account) gin.HandlerFunc { // Generate seed hash from // this instance private key. - priv := instance.PrivateKey + priv := instanceAcc.PrivateKey bpriv := x509.MarshalPKCS1PrivateKey(priv) seed := sha512.Sum512(bpriv)