diff options
Diffstat (limited to 'internal/api')
-rw-r--r-- | internal/api/client/account/accountcreate.go | 12 | ||||
-rw-r--r-- | internal/api/client/admin/emojicreate.go | 4 | ||||
-rw-r--r-- | internal/api/client/auth/auth_test.go | 1 | ||||
-rw-r--r-- | internal/api/client/auth/callback.go | 6 | ||||
-rw-r--r-- | internal/api/client/status/statuscreate.go | 4 | ||||
-rw-r--r-- | internal/api/client/streaming/stream.go | 8 |
6 files changed, 17 insertions, 18 deletions
diff --git a/internal/api/client/account/accountcreate.go b/internal/api/client/account/accountcreate.go index a9d672f80..3fab1488f 100644 --- a/internal/api/client/account/accountcreate.go +++ b/internal/api/client/account/accountcreate.go @@ -27,7 +27,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/oauth" - "github.com/superseriousbusiness/gotosocial/internal/util" + "github.com/superseriousbusiness/gotosocial/internal/validate" ) // AccountCreatePOSTHandler swagger:operation POST /api/v1/accounts accountCreate @@ -118,15 +118,15 @@ func validateCreateAccount(form *model.AccountCreateRequest, c *config.AccountsC return errors.New("registration is not open for this server") } - if err := util.ValidateUsername(form.Username); err != nil { + if err := validate.Username(form.Username); err != nil { return err } - if err := util.ValidateEmail(form.Email); err != nil { + if err := validate.Email(form.Email); err != nil { return err } - if err := util.ValidateNewPassword(form.Password); err != nil { + if err := validate.NewPassword(form.Password); err != nil { return err } @@ -134,11 +134,11 @@ func validateCreateAccount(form *model.AccountCreateRequest, c *config.AccountsC return errors.New("agreement to terms and conditions not given") } - if err := util.ValidateLanguage(form.Locale); err != nil { + if err := validate.Language(form.Locale); err != nil { return err } - if err := util.ValidateSignUpReason(form.Reason, c.ReasonRequired); err != nil { + if err := validate.SignUpReason(form.Reason, c.ReasonRequired); err != nil { return err } diff --git a/internal/api/client/admin/emojicreate.go b/internal/api/client/admin/emojicreate.go index 859933b16..019298976 100644 --- a/internal/api/client/admin/emojicreate.go +++ b/internal/api/client/admin/emojicreate.go @@ -28,7 +28,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/media" "github.com/superseriousbusiness/gotosocial/internal/oauth" - "github.com/superseriousbusiness/gotosocial/internal/util" + "github.com/superseriousbusiness/gotosocial/internal/validate" ) // emojiCreateRequest swagger:operation POST /api/v1/admin/custom_emojis emojiCreate @@ -132,5 +132,5 @@ func validateCreateEmoji(form *model.EmojiCreateRequest) error { return fmt.Errorf("file size limit exceeded: limit is %d bytes but emoji was %d bytes", media.EmojiMaxBytes, form.Image.Size) } - return util.ValidateEmojiShortcode(form.Shortcode) + return validate.EmojiShortcode(form.Shortcode) } diff --git a/internal/api/client/auth/auth_test.go b/internal/api/client/auth/auth_test.go index 9b778ad1d..295c0e964 100644 --- a/internal/api/client/auth/auth_test.go +++ b/internal/api/client/auth/auth_test.go @@ -95,7 +95,6 @@ func (suite *AuthTestSuite) SetupSuite() { ClientID: "a-known-client-id", ClientSecret: "some-secret", Scopes: "read", - VapidKey: uuid.NewString(), } } diff --git a/internal/api/client/auth/callback.go b/internal/api/client/auth/callback.go index c2fbfb486..322ba5fc9 100644 --- a/internal/api/client/auth/callback.go +++ b/internal/api/client/auth/callback.go @@ -33,7 +33,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/oidc" - "github.com/superseriousbusiness/gotosocial/internal/util" + "github.com/superseriousbusiness/gotosocial/internal/validate" ) // CallbackGETHandler parses a token from an external auth provider. @@ -153,7 +153,7 @@ func (m *Module) parseUserFromClaims(ctx context.Context, claims *oidc.Claims, i } // check if we can just use claims.Name as-is - err = util.ValidateUsername(claims.Name) + err = validate.Username(claims.Name) if err == nil { // the name we have on the claims is already a valid username username = claims.Name @@ -166,7 +166,7 @@ func (m *Module) parseUserFromClaims(ctx context.Context, claims *oidc.Claims, i // lowercase the whole thing lower := strings.ToLower(underscored) // see if this is valid.... - if err := util.ValidateUsername(lower); err == nil { + if err := validate.Username(lower); err == nil { // we managed to get a valid username username = lower } else { diff --git a/internal/api/client/status/statuscreate.go b/internal/api/client/status/statuscreate.go index 09fc47b5b..c8ea019d2 100644 --- a/internal/api/client/status/statuscreate.go +++ b/internal/api/client/status/statuscreate.go @@ -27,7 +27,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/oauth" - "github.com/superseriousbusiness/gotosocial/internal/util" + "github.com/superseriousbusiness/gotosocial/internal/validate" ) // StatusCreatePOSTHandler swagger:operation POST /api/v1/statuses statusCreate @@ -157,7 +157,7 @@ func validateCreateStatus(form *model.AdvancedStatusCreateForm, config *config.S // validate post language if form.Language != "" { - if err := util.ValidateLanguage(form.Language); err != nil { + if err := validate.Language(form.Language); err != nil { return err } } diff --git a/internal/api/client/streaming/stream.go b/internal/api/client/streaming/stream.go index fa210e8d8..4a9dcfe52 100644 --- a/internal/api/client/streaming/stream.go +++ b/internal/api/client/streaming/stream.go @@ -146,13 +146,13 @@ func (m *Module) StreamGETHandler(c *gin.Context) { } defer conn.Close() // whatever happens, when we leave this function we want to close the websocket connection - // inform the processor that we have a new connection and want a stream for it - stream, errWithCode := m.processor.OpenStreamForAccount(c.Request.Context(), account, streamType) + // inform the processor that we have a new connection and want a s for it + s, errWithCode := m.processor.OpenStreamForAccount(c.Request.Context(), account, streamType) if errWithCode != nil { c.JSON(errWithCode.Code(), errWithCode.Safe()) return } - defer close(stream.Hangup) // closing stream.Hangup indicates that we've finished with the connection (the client has gone), so we want to do this on exiting this handler + defer close(s.Hangup) // closing stream.Hangup indicates that we've finished with the connection (the client has gone), so we want to do this on exiting this handler // spawn a new ticker for pinging the connection periodically t := time.NewTicker(30 * time.Second) @@ -161,7 +161,7 @@ func (m *Module) StreamGETHandler(c *gin.Context) { sendLoop: for { select { - case m := <-stream.Messages: + case m := <-s.Messages: // we've got a streaming message!! l.Trace("received message from stream") if err := conn.WriteJSON(m); err != nil { |