mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 01:52:26 -05:00
Api/v1/statuses (#11)
This PR adds:
Statuses
New status creation.
View existing status
Delete a status
Fave a status
Unfave a status
See who's faved a status
Media
Upload media attachment and store/retrieve it
Upload custom emoji and store/retrieve it
Fileserver
Serve files from storage
Testing
Test models, testrig -- run a GTS test instance and play around with it.
This commit is contained in:
parent
71a49e2b43
commit
32c5fd987a
150 changed files with 9023 additions and 788 deletions
|
|
@ -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{},
|
||||
>smodel.User{},
|
||||
>smodel.Account{},
|
||||
>smodel.Follow{},
|
||||
>smodel.FollowRequest{},
|
||||
>smodel.Status{},
|
||||
>smodel.Application{},
|
||||
>smodel.EmailDomainBlock{},
|
||||
>smodel.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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue