summaryrefslogtreecommitdiff
path: root/internal/gotosocial/actions.go
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-04-19 19:42:19 +0200
committerLibravatar GitHub <noreply@github.com>2021-04-19 19:42:19 +0200
commit32c5fd987a06e11b14a4247d13187657c14adedd (patch)
treef5b787ca0f020bea5fd020925e52d3592a77a6ad /internal/gotosocial/actions.go
parentApi/v1/accounts (#8) (diff)
downloadgotosocial-32c5fd987a06e11b14a4247d13187657c14adedd.tar.xz
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.
Diffstat (limited to 'internal/gotosocial/actions.go')
-rw-r--r--internal/gotosocial/actions.go39
1 files changed, 35 insertions, 4 deletions
diff --git a/internal/gotosocial/actions.go b/internal/gotosocial/actions.go
index 03d90217e..2f90858b4 100644
--- a/internal/gotosocial/actions.go
+++ b/internal/gotosocial/actions.go
@@ -29,12 +29,19 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/action"
"github.com/superseriousbusiness/gotosocial/internal/apimodule"
"github.com/superseriousbusiness/gotosocial/internal/apimodule/account"
+ "github.com/superseriousbusiness/gotosocial/internal/apimodule/admin"
"github.com/superseriousbusiness/gotosocial/internal/apimodule/app"
"github.com/superseriousbusiness/gotosocial/internal/apimodule/auth"
+ "github.com/superseriousbusiness/gotosocial/internal/apimodule/fileserver"
+ mediaModule "github.com/superseriousbusiness/gotosocial/internal/apimodule/media"
+ "github.com/superseriousbusiness/gotosocial/internal/apimodule/security"
+ "github.com/superseriousbusiness/gotosocial/internal/apimodule/status"
"github.com/superseriousbusiness/gotosocial/internal/cache"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db"
+ "github.com/superseriousbusiness/gotosocial/internal/distributor"
"github.com/superseriousbusiness/gotosocial/internal/federation"
+ "github.com/superseriousbusiness/gotosocial/internal/mastotypes"
"github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/router"
@@ -53,7 +60,7 @@ var Run action.GTSAction = func(ctx context.Context, c *config.Config, log *logr
return fmt.Errorf("error creating router: %s", err)
}
- storageBackend, err := storage.NewInMem(c, log)
+ storageBackend, err := storage.NewLocal(c, log)
if err != nil {
return fmt.Errorf("error creating storage backend: %s", err)
}
@@ -61,16 +68,36 @@ var Run action.GTSAction = func(ctx context.Context, c *config.Config, log *logr
// build backend handlers
mediaHandler := media.New(c, dbService, storageBackend, log)
oauthServer := oauth.New(dbService, log)
+ distributor := distributor.New(log)
+ if err := distributor.Start(); err != nil {
+ return fmt.Errorf("error starting distributor: %s", err)
+ }
+
+ // build converters and util
+ mastoConverter := mastotypes.New(c, dbService)
// build client api modules
authModule := auth.New(oauthServer, dbService, log)
- accountModule := account.New(c, dbService, oauthServer, mediaHandler, log)
- appsModule := app.New(oauthServer, dbService, log)
+ accountModule := account.New(c, dbService, oauthServer, mediaHandler, mastoConverter, log)
+ appsModule := app.New(oauthServer, dbService, mastoConverter, log)
+ mm := mediaModule.New(dbService, mediaHandler, mastoConverter, c, log)
+ fileServerModule := fileserver.New(c, dbService, storageBackend, log)
+ adminModule := admin.New(c, dbService, mediaHandler, mastoConverter, log)
+ statusModule := status.New(c, dbService, mediaHandler, mastoConverter, distributor, log)
+ securityModule := security.New(c, log)
apiModules := []apimodule.ClientAPIModule{
- authModule, // this one has to go first so the other modules use its middleware
+ // modules with middleware go first
+ securityModule,
+ authModule,
+
+ // now everything else
accountModule,
appsModule,
+ mm,
+ fileServerModule,
+ adminModule,
+ statusModule,
}
for _, m := range apiModules {
@@ -82,6 +109,10 @@ var Run action.GTSAction = func(ctx context.Context, c *config.Config, log *logr
}
}
+ if err := dbService.CreateInstanceAccount(); err != nil {
+ return fmt.Errorf("error creating instance account: %s", err)
+ }
+
gts, err := New(dbService, &cache.MockCache{}, router, federation.New(dbService, log), c)
if err != nil {
return fmt.Errorf("error creating gotosocial service: %s", err)