summaryrefslogtreecommitdiff
path: root/internal/api/client/streaming/stream.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/client/streaming/stream.go')
-rw-r--r--internal/api/client/streaming/stream.go27
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.