summaryrefslogtreecommitdiff
path: root/internal/apimodule/account/account.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/apimodule/account/account.go')
-rw-r--r--internal/apimodule/account/account.go62
1 files changed, 36 insertions, 26 deletions
diff --git a/internal/apimodule/account/account.go b/internal/apimodule/account/account.go
index 2d9ddbb72..f4a47f6a2 100644
--- a/internal/apimodule/account/account.go
+++ b/internal/apimodule/account/account.go
@@ -28,7 +28,9 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/apimodule"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db"
- "github.com/superseriousbusiness/gotosocial/internal/db/model"
+ "github.com/superseriousbusiness/gotosocial/internal/db/gtsmodel"
+ "github.com/superseriousbusiness/gotosocial/internal/mastotypes"
+
"github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/router"
@@ -43,21 +45,23 @@ const (
)
type accountModule struct {
- config *config.Config
- db db.DB
- oauthServer oauth.Server
- mediaHandler media.MediaHandler
- log *logrus.Logger
+ config *config.Config
+ db db.DB
+ oauthServer oauth.Server
+ mediaHandler media.MediaHandler
+ mastoConverter mastotypes.Converter
+ log *logrus.Logger
}
// New returns a new account module
-func New(config *config.Config, db db.DB, oauthServer oauth.Server, mediaHandler media.MediaHandler, log *logrus.Logger) apimodule.ClientAPIModule {
+func New(config *config.Config, db db.DB, oauthServer oauth.Server, mediaHandler media.MediaHandler, mastoConverter mastotypes.Converter, log *logrus.Logger) apimodule.ClientAPIModule {
return &accountModule{
- config: config,
- db: db,
- oauthServer: oauthServer,
- mediaHandler: mediaHandler,
- log: log,
+ config: config,
+ db: db,
+ oauthServer: oauthServer,
+ mediaHandler: mediaHandler,
+ mastoConverter: mastoConverter,
+ log: log,
}
}
@@ -65,19 +69,20 @@ func New(config *config.Config, db db.DB, oauthServer oauth.Server, mediaHandler
func (m *accountModule) Route(r router.Router) error {
r.AttachHandler(http.MethodPost, basePath, m.accountCreatePOSTHandler)
r.AttachHandler(http.MethodGet, basePathWithID, m.muxHandler)
+ r.AttachHandler(http.MethodPatch, basePathWithID, m.muxHandler)
return nil
}
func (m *accountModule) CreateTables(db db.DB) error {
models := []interface{}{
- &model.User{},
- &model.Account{},
- &model.Follow{},
- &model.FollowRequest{},
- &model.Status{},
- &model.Application{},
- &model.EmailDomainBlock{},
- &model.MediaAttachment{},
+ &gtsmodel.User{},
+ &gtsmodel.Account{},
+ &gtsmodel.Follow{},
+ &gtsmodel.FollowRequest{},
+ &gtsmodel.Status{},
+ &gtsmodel.Application{},
+ &gtsmodel.EmailDomainBlock{},
+ &gtsmodel.MediaAttachment{},
}
for _, m := range models {
@@ -90,11 +95,16 @@ func (m *accountModule) CreateTables(db db.DB) error {
func (m *accountModule) muxHandler(c *gin.Context) {
ru := c.Request.RequestURI
- if strings.HasPrefix(ru, verifyPath) {
- m.accountVerifyGETHandler(c)
- } else if strings.HasPrefix(ru, updateCredentialsPath) {
- m.accountUpdateCredentialsPATCHHandler(c)
- } else {
- m.accountGETHandler(c)
+ switch c.Request.Method {
+ case http.MethodGet:
+ if strings.HasPrefix(ru, verifyPath) {
+ m.accountVerifyGETHandler(c)
+ } else {
+ m.accountGETHandler(c)
+ }
+ case http.MethodPatch:
+ if strings.HasPrefix(ru, updateCredentialsPath) {
+ m.accountUpdateCredentialsPATCHHandler(c)
+ }
}
}