mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-24 11:13:33 -06:00
moving stuff around
This commit is contained in:
parent
684bd56528
commit
4696e1a7b3
93 changed files with 878 additions and 1750 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,6 @@ func (suite *AuthTestSuite) SetupSuite() {
|
|||
ClientID: "a-known-client-id",
|
||||
ClientSecret: "some-secret",
|
||||
Scopes: "read",
|
||||
VapidKey: uuid.NewString(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue