From 91cbcd589e7c4ab87e5994e4d0276ea1248dc5c2 Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Thu, 10 Aug 2023 15:08:41 +0100 Subject: [performance] remove last of relational queries to instead rely on caches (#2091) --- internal/middleware/tokencheck.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'internal/middleware') diff --git a/internal/middleware/tokencheck.go b/internal/middleware/tokencheck.go index 1496363af..d2570c3f0 100644 --- a/internal/middleware/tokencheck.go +++ b/internal/middleware/tokencheck.go @@ -22,7 +22,6 @@ import ( "github.com/gin-gonic/gin" "github.com/superseriousbusiness/gotosocial/internal/db" - "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/log" "github.com/superseriousbusiness/gotosocial/internal/oauth" "github.com/superseriousbusiness/oauth2/v4" @@ -125,8 +124,8 @@ func TokenCheck(dbConn db.DB, validateBearerToken func(r *http.Request) (oauth2. log.Tracef(ctx, "authenticated client %s with bearer token, scope is %s", clientID, ti.GetScope()) // fetch app for this token - app := >smodel.Application{} - if err := dbConn.GetWhere(ctx, []db.Where{{Key: "client_id", Value: clientID}}, app); err != nil { + app, err := dbConn.GetApplicationByClientID(ctx, clientID) + if err != nil { if err != db.ErrNoEntries { log.Errorf(ctx, "database error looking for application with clientID %s: %s", clientID, err) return @@ -134,6 +133,7 @@ func TokenCheck(dbConn db.DB, validateBearerToken func(r *http.Request) (oauth2. log.Warnf(ctx, "no app found for client %s", clientID) return } + c.Set(oauth.SessionAuthorizedApplication, app) } } -- cgit v1.2.3