MCPcopy Create free account
hub / github.com/daodst/chat / QueryAccessToken

Method QueryAccessToken

userapi/internal/api.go:414–442  ·  view source on GitHub ↗
(ctx context.Context, req *api.QueryAccessTokenRequest, res *api.QueryAccessTokenResponse)

Source from the content-addressed store, hash-verified

412}
413
414func (a *UserInternalAPI) QueryAccessToken(ctx context.Context, req *api.QueryAccessTokenRequest, res *api.QueryAccessTokenResponse) error {
415 if req.AppServiceUserID != "" {
416 appServiceDevice, err := a.queryAppServiceToken(ctx, req.AccessToken, req.AppServiceUserID)
417 if err != nil {
418 res.Err = err.Error()
419 }
420 res.Device = appServiceDevice
421
422 return nil
423 }
424 device, err := a.DB.GetDeviceByAccessToken(ctx, req.AccessToken)
425 if err != nil {
426 if err == sql.ErrNoRows {
427 return nil
428 }
429 return err
430 }
431 localPart, _, err := gomatrixserverlib.SplitID('@', device.UserID)
432 if err != nil {
433 return err
434 }
435 acc, err := a.DB.GetAccountByLocalpart(ctx, localPart)
436 if err != nil {
437 return err
438 }
439 device.AccountType = acc.AccountType
440 res.Device = device
441 return nil
442}
443
444// Return the appservice 'device' or nil if the token is not an appservice. Returns an error if there was a problem
445// creating a 'device'.

Callers

nothing calls this directly

Calls 4

queryAppServiceTokenMethod · 0.95
GetAccountByLocalpartMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected