diff options
author | 2023-11-28 11:05:07 +0000 | |
---|---|---|
committer | 2023-11-28 11:05:07 +0000 | |
commit | 2eb8b8eeb41384dbf34989d7a850b4d498d90064 (patch) | |
tree | 132bd8b2504744945a5af0808782b43163044f69 /internal/api/client/streaming/stream.go | |
parent | [bugfix] Don't copy ptr fields in caches (#2386) (diff) | |
download | gotosocial-2eb8b8eeb41384dbf34989d7a850b4d498d90064.tar.xz |
[chore]: Bump github.com/gorilla/websocket from 1.5.0 to 1.5.1 (#2335)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/api/client/streaming/stream.go')
-rw-r--r-- | internal/api/client/streaming/stream.go | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/internal/api/client/streaming/stream.go b/internal/api/client/streaming/stream.go index 1f34e3447..2d1c48341 100644 --- a/internal/api/client/streaming/stream.go +++ b/internal/api/client/streaming/stream.go @@ -162,24 +162,27 @@ func (m *Module) StreamGETHandler(c *gin.Context) { } if token != "" { + // Token was provided, use it to authorize stream. account, errWithCode = m.processor.Stream().Authorize(c.Request.Context(), token) + if errWithCode != nil { + apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1) + return + } + } else { + // No explicit token was provided: // try regular oauth as a last resort. - account, errWithCode = func() (*gtsmodel.Account, gtserror.WithCode) { - authed, err := oauth.Authed(c, true, true, true, true) - if err != nil { - return nil, gtserror.NewErrorUnauthorized(err, err.Error()) - } - - return authed.Account, nil - }() - } + authed, err := oauth.Authed(c, true, true, true, true) + if err != nil { + errWithCode := gtserror.NewErrorUnauthorized(err, err.Error()) + apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1) + return + } - if errWithCode != nil { - apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1) - return + // Set the auth'ed account. + account = authed.Account } // Get the initial requested stream type, if there is one. |