reference global logrus (#274)

* reference logrus' global logger instead of passing and storing a logger reference everywhere

* always directly use global logrus logger instead of referencing an instance

* test suites should also directly use the global logrus logger

* rename gin logging function to clarify that it's middleware

* correct comments which erroneously referenced removed logger parameter

* setting log level for tests now uses logrus' exported type instead of the string value, to guarantee error isn't possible
This commit is contained in:
R. Aidan Campbell 2021-10-11 05:37:33 -07:00 committed by GitHub
parent 367bdca250
commit 083099a957
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
210 changed files with 506 additions and 662 deletions

View File

@ -41,11 +41,11 @@ func runAction(c *cli.Context, a cliactions.GTSAction) error {
return fmt.Errorf("error parsing config: %s", err) return fmt.Errorf("error parsing config: %s", err)
} }
// create a logger with the log level, formatting, and output splitter already set // initialize the global logger to the log level, with formatting and output splitter already set
log, err := log.New(conf.LogLevel) err = log.Initialize(conf.LogLevel)
if err != nil { if err != nil {
return fmt.Errorf("error creating logger: %s", err) return fmt.Errorf("error creating logger: %s", err)
} }
return a(c.Context, conf, log) return a(c.Context, conf)
} }

View File

@ -23,7 +23,6 @@
"strings" "strings"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -75,15 +74,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new account module // New returns a new account module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule { func New(config *config.Config, processor processing.Processor) api.ClientModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }

View File

@ -8,7 +8,6 @@
"git.iim.gay/grufwub/go-store/kv" "git.iim.gay/grufwub/go-store/kv"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/api/client/account" "github.com/superseriousbusiness/gotosocial/internal/api/client/account"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
@ -26,7 +25,6 @@ type AccountStandardTestSuite struct {
suite.Suite suite.Suite
config *config.Config config *config.Config
db db.DB db db.DB
log *logrus.Logger
tc typeutils.TypeConverter tc typeutils.TypeConverter
storage *kv.KVStore storage *kv.KVStore
federator federation.Federator federator federation.Federator
@ -59,10 +57,10 @@ func (suite *AccountStandardTestSuite) SetupTest() {
suite.config = testrig.NewTestConfig() suite.config = testrig.NewTestConfig()
suite.db = testrig.NewTestDB() suite.db = testrig.NewTestDB()
suite.storage = testrig.NewTestStorage() suite.storage = testrig.NewTestStorage()
suite.log = testrig.NewTestLog() testrig.InitTestLog()
suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage) suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator) suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator)
suite.accountModule = account.New(suite.config, suite.processor, suite.log).(*account.Module) suite.accountModule = account.New(suite.config, suite.processor).(*account.Module)
testrig.StandardDBSetup(suite.db, nil) testrig.StandardDBSetup(suite.db, nil)
testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media") testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media")
} }

View File

@ -20,6 +20,7 @@
import ( import (
"errors" "errors"
"github.com/sirupsen/logrus"
"net" "net"
"net/http" "net/http"
@ -67,7 +68,7 @@
// '500': // '500':
// description: internal error // description: internal error
func (m *Module) AccountCreatePOSTHandler(c *gin.Context) { func (m *Module) AccountCreatePOSTHandler(c *gin.Context) {
l := m.log.WithField("func", "accountCreatePOSTHandler") l := logrus.WithField("func", "accountCreatePOSTHandler")
authed, err := oauth.Authed(c, true, true, false, false) authed, err := oauth.Authed(c, true, true, false, false)
if err != nil { if err != nil {
l.Debugf("couldn't auth: %s", err) l.Debugf("couldn't auth: %s", err)

View File

@ -20,6 +20,7 @@
import ( import (
"fmt" "fmt"
"github.com/sirupsen/logrus"
"net/http" "net/http"
"strconv" "strconv"
@ -100,7 +101,7 @@
// '400': // '400':
// description: bad request // description: bad request
func (m *Module) AccountUpdateCredentialsPATCHHandler(c *gin.Context) { func (m *Module) AccountUpdateCredentialsPATCHHandler(c *gin.Context) {
l := m.log.WithField("func", "accountUpdateCredentialsPATCHHandler") l := logrus.WithField("func", "accountUpdateCredentialsPATCHHandler")
authed, err := oauth.Authed(c, true, true, true, true) authed, err := oauth.Authed(c, true, true, true, true)
if err != nil { if err != nil {
l.Debugf("couldn't auth: %s", err) l.Debugf("couldn't auth: %s", err)

View File

@ -19,6 +19,7 @@
package account package account
import ( import (
"github.com/sirupsen/logrus"
"net/http" "net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -51,7 +52,7 @@
// '404': // '404':
// description: not found // description: not found
func (m *Module) AccountVerifyGETHandler(c *gin.Context) { func (m *Module) AccountVerifyGETHandler(c *gin.Context) {
l := m.log.WithField("func", "accountVerifyGETHandler") l := logrus.WithField("func", "accountVerifyGETHandler")
authed, err := oauth.Authed(c, true, false, false, true) authed, err := oauth.Authed(c, true, false, false, true)
if err != nil { if err != nil {
l.Debugf("couldn't auth: %s", err) l.Debugf("couldn't auth: %s", err)

View File

@ -1,6 +1,7 @@
package account package account
import ( import (
"github.com/sirupsen/logrus"
"net/http" "net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -47,7 +48,7 @@
// '404': // '404':
// description: not found // description: not found
func (m *Module) AccountRelationshipsGETHandler(c *gin.Context) { func (m *Module) AccountRelationshipsGETHandler(c *gin.Context) {
l := m.log.WithField("func", "AccountRelationshipsGETHandler") l := logrus.WithField("func", "AccountRelationshipsGETHandler")
authed, err := oauth.Authed(c, true, true, true, true) authed, err := oauth.Authed(c, true, true, true, true)
if err != nil { if err != nil {

View File

@ -19,6 +19,7 @@
package account package account
import ( import (
"github.com/sirupsen/logrus"
"net/http" "net/http"
"strconv" "strconv"
@ -96,7 +97,7 @@
// '404': // '404':
// description: not found // description: not found
func (m *Module) AccountStatusesGETHandler(c *gin.Context) { func (m *Module) AccountStatusesGETHandler(c *gin.Context) {
l := m.log.WithField("func", "AccountStatusesGETHandler") l := logrus.WithField("func", "AccountStatusesGETHandler")
authed, err := oauth.Authed(c, false, false, false, false) authed, err := oauth.Authed(c, false, false, false, false)
if err != nil { if err != nil {

View File

@ -19,6 +19,7 @@
package account package account
import ( import (
"github.com/sirupsen/logrus"
"net/http" "net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -60,7 +61,7 @@
// '404': // '404':
// description: not found // description: not found
func (m *Module) AccountUnfollowPOSTHandler(c *gin.Context) { func (m *Module) AccountUnfollowPOSTHandler(c *gin.Context) {
l := m.log.WithField("func", "AccountUnfollowPOSTHandler") l := logrus.WithField("func", "AccountUnfollowPOSTHandler")
authed, err := oauth.Authed(c, true, true, true, true) authed, err := oauth.Authed(c, true, true, true, true)
if err != nil { if err != nil {
l.Debug(err) l.Debug(err)

View File

@ -21,7 +21,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -50,15 +49,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new admin module // New returns a new admin module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule { func New(config *config.Config, processor processing.Processor) api.ClientModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }

View File

@ -90,7 +90,7 @@
// '400': // '400':
// description: bad request // description: bad request
func (m *Module) DomainBlocksPOSTHandler(c *gin.Context) { func (m *Module) DomainBlocksPOSTHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "DomainBlocksPOSTHandler", "func": "DomainBlocksPOSTHandler",
"request_uri": c.Request.RequestURI, "request_uri": c.Request.RequestURI,
"user_agent": c.Request.UserAgent(), "user_agent": c.Request.UserAgent(),

View File

@ -42,7 +42,7 @@
// '404': // '404':
// description: not found // description: not found
func (m *Module) DomainBlockDELETEHandler(c *gin.Context) { func (m *Module) DomainBlockDELETEHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "DomainBlockDELETEHandler", "func": "DomainBlockDELETEHandler",
"request_uri": c.Request.RequestURI, "request_uri": c.Request.RequestURI,
"user_agent": c.Request.UserAgent(), "user_agent": c.Request.UserAgent(),

View File

@ -43,7 +43,7 @@
// '404': // '404':
// description: not found // description: not found
func (m *Module) DomainBlockGETHandler(c *gin.Context) { func (m *Module) DomainBlockGETHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "DomainBlockGETHandler", "func": "DomainBlockGETHandler",
"request_uri": c.Request.RequestURI, "request_uri": c.Request.RequestURI,
"user_agent": c.Request.UserAgent(), "user_agent": c.Request.UserAgent(),

View File

@ -49,7 +49,7 @@
// '404': // '404':
// description: not found // description: not found
func (m *Module) DomainBlocksGETHandler(c *gin.Context) { func (m *Module) DomainBlocksGETHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "DomainBlocksGETHandler", "func": "DomainBlocksGETHandler",
"request_uri": c.Request.RequestURI, "request_uri": c.Request.RequestURI,
"user_agent": c.Request.UserAgent(), "user_agent": c.Request.UserAgent(),

View File

@ -74,7 +74,7 @@
// '400': // '400':
// description: bad request // description: bad request
func (m *Module) emojiCreatePOSTHandler(c *gin.Context) { func (m *Module) emojiCreatePOSTHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "emojiCreatePOSTHandler", "func": "emojiCreatePOSTHandler",
"request_uri": c.Request.RequestURI, "request_uri": c.Request.RequestURI,
"user_agent": c.Request.UserAgent(), "user_agent": c.Request.UserAgent(),

View File

@ -21,7 +21,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -35,15 +34,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new auth module // New returns a new auth module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule { func New(config *config.Config, processor processing.Processor) api.ClientModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }

View File

@ -20,6 +20,7 @@
import ( import (
"fmt" "fmt"
"github.com/sirupsen/logrus"
"net/http" "net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -63,7 +64,7 @@
// '500': // '500':
// description: internal error // description: internal error
func (m *Module) AppsPOSTHandler(c *gin.Context) { func (m *Module) AppsPOSTHandler(c *gin.Context) {
l := m.log.WithField("func", "AppsPOSTHandler") l := logrus.WithField("func", "AppsPOSTHandler")
l.Trace("entering AppsPOSTHandler") l.Trace("entering AppsPOSTHandler")
authed, err := oauth.Authed(c, false, false, false, false) authed, err := oauth.Authed(c, false, false, false, false)

View File

@ -21,7 +21,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/db"
@ -58,17 +57,15 @@ type Module struct {
db db.DB db db.DB
server oauth.Server server oauth.Server
idp oidc.IDP idp oidc.IDP
log *logrus.Logger
} }
// New returns a new auth module // New returns a new auth module
func New(config *config.Config, db db.DB, server oauth.Server, idp oidc.IDP, log *logrus.Logger) api.ClientModule { func New(config *config.Config, db db.DB, server oauth.Server, idp oidc.IDP) api.ClientModule {
return &Module{ return &Module{
config: config, config: config,
db: db, db: db,
server: server, server: server,
idp: idp, idp: idp,
log: log,
} }
} }

View File

@ -103,7 +103,7 @@ func (suite *AuthTestSuite) SetupTest() {
log := logrus.New() log := logrus.New()
log.SetLevel(logrus.TraceLevel) log.SetLevel(logrus.TraceLevel)
db, err := bundb.NewBunDBService(context.Background(), suite.config, log) db, err := bundb.NewBunDBService(context.Background(), suite.config)
if err != nil { if err != nil {
logrus.Panicf("error creating database connection: %s", err) logrus.Panicf("error creating database connection: %s", err)
} }
@ -124,7 +124,7 @@ func (suite *AuthTestSuite) SetupTest() {
} }
} }
suite.oauthServer = oauth.New(context.Background(), suite.db, log) suite.oauthServer = oauth.New(context.Background(), suite.db)
if err := suite.db.Put(context.Background(), suite.testAccount); err != nil { if err := suite.db.Put(context.Background(), suite.testAccount); err != nil {
logrus.Panicf("could not insert test account into db: %s", err) logrus.Panicf("could not insert test account into db: %s", err)

View File

@ -21,6 +21,7 @@
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/sirupsen/logrus"
"net/http" "net/http"
"net/url" "net/url"
"strings" "strings"
@ -37,7 +38,7 @@
// The idea here is to present an oauth authorize page to the user, with a button // The idea here is to present an oauth authorize page to the user, with a button
// that they have to click to accept. // that they have to click to accept.
func (m *Module) AuthorizeGETHandler(c *gin.Context) { func (m *Module) AuthorizeGETHandler(c *gin.Context) {
l := m.log.WithField("func", "AuthorizeGETHandler") l := logrus.WithField("func", "AuthorizeGETHandler")
s := sessions.Default(c) s := sessions.Default(c)
// UserID will be set in the session by AuthorizePOSTHandler if the caller has already gone through the authentication flow // UserID will be set in the session by AuthorizePOSTHandler if the caller has already gone through the authentication flow
@ -123,7 +124,7 @@ func (m *Module) AuthorizeGETHandler(c *gin.Context) {
// At this point we assume that the user has A) logged in and B) accepted that the app should act for them, // At this point we assume that the user has A) logged in and B) accepted that the app should act for them,
// so we should proceed with the authentication flow and generate an oauth token for them if we can. // so we should proceed with the authentication flow and generate an oauth token for them if we can.
func (m *Module) AuthorizePOSTHandler(c *gin.Context) { func (m *Module) AuthorizePOSTHandler(c *gin.Context) {
l := m.log.WithField("func", "AuthorizePOSTHandler") l := logrus.WithField("func", "AuthorizePOSTHandler")
s := sessions.Default(c) s := sessions.Default(c)
// We need to retrieve the original form submitted to the authorizeGEThandler, and // We need to retrieve the original form submitted to the authorizeGEThandler, and

View File

@ -20,6 +20,7 @@
import ( import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/oauth" "github.com/superseriousbusiness/gotosocial/internal/oauth"
@ -31,7 +32,7 @@
// If user or account can't be found, then the handler won't *fail*, in case the server wants to allow // If user or account can't be found, then the handler won't *fail*, in case the server wants to allow
// public requests that don't have a Bearer token set (eg., for public instance information and so on). // public requests that don't have a Bearer token set (eg., for public instance information and so on).
func (m *Module) OauthTokenMiddleware(c *gin.Context) { func (m *Module) OauthTokenMiddleware(c *gin.Context) {
l := m.log.WithField("func", "OauthTokenMiddleware") l := logrus.WithField("func", "OauthTokenMiddleware")
l.Trace("entering OauthTokenMiddleware") l.Trace("entering OauthTokenMiddleware")
ti, err := m.server.ValidationBearerToken(c.Copy().Request) ti, err := m.server.ValidationBearerToken(c.Copy().Request)

View File

@ -21,6 +21,7 @@
import ( import (
"context" "context"
"errors" "errors"
"github.com/sirupsen/logrus"
"net/http" "net/http"
"github.com/gin-contrib/sessions" "github.com/gin-contrib/sessions"
@ -40,7 +41,7 @@ type login struct {
// The idea is to present a sign in page to the user, where they can enter their username and password. // The idea is to present a sign in page to the user, where they can enter their username and password.
// The form will then POST to the sign in page, which will be handled by SignInPOSTHandler // The form will then POST to the sign in page, which will be handled by SignInPOSTHandler
func (m *Module) SignInGETHandler(c *gin.Context) { func (m *Module) SignInGETHandler(c *gin.Context) {
l := m.log.WithField("func", "SignInGETHandler") l := logrus.WithField("func", "SignInGETHandler")
l.Trace("entering sign in handler") l.Trace("entering sign in handler")
if m.idp != nil { if m.idp != nil {
s := sessions.Default(c) s := sessions.Default(c)
@ -65,7 +66,7 @@ func (m *Module) SignInGETHandler(c *gin.Context) {
// The idea is to present a sign in page to the user, where they can enter their username and password. // The idea is to present a sign in page to the user, where they can enter their username and password.
// The handler will then redirect to the auth handler served at /auth // The handler will then redirect to the auth handler served at /auth
func (m *Module) SignInPOSTHandler(c *gin.Context) { func (m *Module) SignInPOSTHandler(c *gin.Context) {
l := m.log.WithField("func", "SignInPOSTHandler") l := logrus.WithField("func", "SignInPOSTHandler")
s := sessions.Default(c) s := sessions.Default(c)
form := &login{} form := &login{}
if err := c.ShouldBind(form); err != nil { if err := c.ShouldBind(form); err != nil {
@ -98,7 +99,7 @@ func (m *Module) SignInPOSTHandler(c *gin.Context) {
// address stored in the database. If OK, we return the userid (a ulid) for that user, // address stored in the database. If OK, we return the userid (a ulid) for that user,
// so that it can be used in further Oauth flows to generate a token/retreieve an oauth client from the db. // so that it can be used in further Oauth flows to generate a token/retreieve an oauth client from the db.
func (m *Module) ValidatePassword(ctx context.Context, email string, password string) (userid string, err error) { func (m *Module) ValidatePassword(ctx context.Context, email string, password string) (userid string, err error) {
l := m.log.WithField("func", "ValidatePassword") l := logrus.WithField("func", "ValidatePassword")
// make sure an email/password was provided and bail if not // make sure an email/password was provided and bail if not
if email == "" || password == "" { if email == "" || password == "" {

View File

@ -19,6 +19,7 @@
package auth package auth
import ( import (
"github.com/sirupsen/logrus"
"net/http" "net/http"
"net/url" "net/url"
@ -37,7 +38,7 @@ type tokenBody struct {
// TokenPOSTHandler should be served as a POST at https://example.org/oauth/token // TokenPOSTHandler should be served as a POST at https://example.org/oauth/token
// The idea here is to serve an oauth access token to a user, which can be used for authorizing against non-public APIs. // The idea here is to serve an oauth access token to a user, which can be used for authorizing against non-public APIs.
func (m *Module) TokenPOSTHandler(c *gin.Context) { func (m *Module) TokenPOSTHandler(c *gin.Context) {
l := m.log.WithField("func", "TokenPOSTHandler") l := logrus.WithField("func", "TokenPOSTHandler")
l.Trace("entered TokenPOSTHandler") l.Trace("entered TokenPOSTHandler")
form := &tokenBody{} form := &tokenBody{}

View File

@ -21,7 +21,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -44,15 +43,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new blocks module // New returns a new blocks module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule { func New(config *config.Config, processor processing.Processor) api.ClientModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }

View File

@ -19,6 +19,7 @@
package blocks package blocks
import ( import (
"github.com/sirupsen/logrus"
"net/http" "net/http"
"strconv" "strconv"
@ -84,7 +85,7 @@
// '404': // '404':
// description: not found // description: not found
func (m *Module) BlocksGETHandler(c *gin.Context) { func (m *Module) BlocksGETHandler(c *gin.Context) {
l := m.log.WithField("func", "PublicTimelineGETHandler") l := logrus.WithField("func", "PublicTimelineGETHandler")
authed, err := oauth.Authed(c, true, true, true, true) authed, err := oauth.Authed(c, true, true, true, true)
if err != nil { if err != nil {

View File

@ -21,7 +21,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -37,15 +36,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new emoji module // New returns a new emoji module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule { func New(config *config.Config, processor processing.Processor) api.ClientModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }

View File

@ -21,7 +21,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -48,15 +47,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new favourites module // New returns a new favourites module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule { func New(config *config.Config, processor processing.Processor) api.ClientModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }

View File

@ -1,6 +1,7 @@
package favourites package favourites
import ( import (
"github.com/sirupsen/logrus"
"net/http" "net/http"
"strconv" "strconv"
@ -10,7 +11,7 @@
// FavouritesGETHandler handles GETting favourites. // FavouritesGETHandler handles GETting favourites.
func (m *Module) FavouritesGETHandler(c *gin.Context) { func (m *Module) FavouritesGETHandler(c *gin.Context) {
l := m.log.WithField("func", "PublicTimelineGETHandler") l := logrus.WithField("func", "PublicTimelineGETHandler")
authed, err := oauth.Authed(c, true, true, true, true) authed, err := oauth.Authed(c, true, true, true, true)
if err != nil { if err != nil {

View File

@ -22,7 +22,6 @@
"fmt" "fmt"
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -45,16 +44,14 @@
type FileServer struct { type FileServer struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
storageBase string storageBase string
} }
// New returns a new fileServer module // New returns a new fileServer module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule { func New(config *config.Config, processor processing.Processor) api.ClientModule {
return &FileServer{ return &FileServer{
config: config, config: config,
processor: processor, processor: processor,
log: log,
storageBase: config.StorageConfig.ServeBasePath, storageBase: config.StorageConfig.ServeBasePath,
} }
} }

View File

@ -33,7 +33,7 @@
// Note: to mitigate scraping attempts, no information should be given out on a bad request except "404 page not found". // Note: to mitigate scraping attempts, no information should be given out on a bad request except "404 page not found".
// Don't give away account ids or media ids or anything like that; callers shouldn't be able to infer anything. // Don't give away account ids or media ids or anything like that; callers shouldn't be able to infer anything.
func (m *FileServer) ServeFile(c *gin.Context) { func (m *FileServer) ServeFile(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "ServeFile", "func": "ServeFile",
"request_uri": c.Request.RequestURI, "request_uri": c.Request.RequestURI,
"user_agent": c.Request.UserAgent(), "user_agent": c.Request.UserAgent(),

View File

@ -48,7 +48,6 @@ type ServeFileTestSuite struct {
suite.Suite suite.Suite
config *config.Config config *config.Config
db db.DB db db.DB
log *logrus.Logger
storage *kv.KVStore storage *kv.KVStore
federator federation.Federator federator federation.Federator
tc typeutils.TypeConverter tc typeutils.TypeConverter
@ -76,7 +75,7 @@ func (suite *ServeFileTestSuite) SetupSuite() {
// setup standard items // setup standard items
suite.config = testrig.NewTestConfig() suite.config = testrig.NewTestConfig()
suite.db = testrig.NewTestDB() suite.db = testrig.NewTestDB()
suite.log = testrig.NewTestLog() testrig.InitTestLog()
suite.storage = testrig.NewTestStorage() suite.storage = testrig.NewTestStorage()
suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage) suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator) suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator)
@ -85,7 +84,7 @@ func (suite *ServeFileTestSuite) SetupSuite() {
suite.oauthServer = testrig.NewTestOauthServer(suite.db) suite.oauthServer = testrig.NewTestOauthServer(suite.db)
// setup module being tested // setup module being tested
suite.fileServer = fileserver.New(suite.config, suite.processor, suite.log).(*fileserver.FileServer) suite.fileServer = fileserver.New(suite.config, suite.processor).(*fileserver.FileServer)
} }
func (suite *ServeFileTestSuite) TearDownSuite() { func (suite *ServeFileTestSuite) TearDownSuite() {

View File

@ -21,7 +21,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -37,15 +36,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new filter module // New returns a new filter module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule { func New(config *config.Config, processor processing.Processor) api.ClientModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }

View File

@ -19,6 +19,7 @@
package followrequest package followrequest
import ( import (
"github.com/sirupsen/logrus"
"net/http" "net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -28,7 +29,7 @@
// FollowRequestAcceptPOSTHandler deals with follow request accepting. It should be served at // FollowRequestAcceptPOSTHandler deals with follow request accepting. It should be served at
// /api/v1/follow_requests/:id/authorize // /api/v1/follow_requests/:id/authorize
func (m *Module) FollowRequestAcceptPOSTHandler(c *gin.Context) { func (m *Module) FollowRequestAcceptPOSTHandler(c *gin.Context) {
l := m.log.WithField("func", "statusCreatePOSTHandler") l := logrus.WithField("func", "statusCreatePOSTHandler")
authed, err := oauth.Authed(c, true, true, true, true) authed, err := oauth.Authed(c, true, true, true, true)
if err != nil { if err != nil {
l.Debugf("couldn't auth: %s", err) l.Debugf("couldn't auth: %s", err)

View File

@ -21,7 +21,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -47,15 +46,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new follow request module // New returns a new follow request module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule { func New(config *config.Config, processor processing.Processor) api.ClientModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }

View File

@ -19,6 +19,7 @@
package followrequest package followrequest
import ( import (
"github.com/sirupsen/logrus"
"net/http" "net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -27,7 +28,7 @@
// FollowRequestGETHandler allows clients to get a list of their incoming follow requests. // FollowRequestGETHandler allows clients to get a list of their incoming follow requests.
func (m *Module) FollowRequestGETHandler(c *gin.Context) { func (m *Module) FollowRequestGETHandler(c *gin.Context) {
l := m.log.WithField("func", "statusCreatePOSTHandler") l := logrus.WithField("func", "statusCreatePOSTHandler")
authed, err := oauth.Authed(c, true, true, true, true) authed, err := oauth.Authed(c, true, true, true, true)
if err != nil { if err != nil {
l.Debugf("couldn't auth: %s", err) l.Debugf("couldn't auth: %s", err)

View File

@ -3,7 +3,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -19,15 +18,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new instance information module // New returns a new instance information module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule { func New(config *config.Config, processor processing.Processor) api.ClientModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }

View File

@ -1,6 +1,7 @@
package instance package instance
import ( import (
"github.com/sirupsen/logrus"
"net/http" "net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -29,7 +30,7 @@
// '500': // '500':
// description: internal error // description: internal error
func (m *Module) InstanceInformationGETHandler(c *gin.Context) { func (m *Module) InstanceInformationGETHandler(c *gin.Context) {
l := m.log.WithField("func", "InstanceInformationGETHandler") l := logrus.WithField("func", "InstanceInformationGETHandler")
instance, err := m.processor.InstanceGet(c.Request.Context(), m.config.Host) instance, err := m.processor.InstanceGet(c.Request.Context(), m.config.Host)
if err != nil { if err != nil {

View File

@ -1,6 +1,7 @@
package instance package instance
import ( import (
"github.com/sirupsen/logrus"
"net/http" "net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -84,7 +85,7 @@
// '400': // '400':
// description: bad request // description: bad request
func (m *Module) InstanceUpdatePATCHHandler(c *gin.Context) { func (m *Module) InstanceUpdatePATCHHandler(c *gin.Context) {
l := m.log.WithField("func", "InstanceUpdatePATCHHandler") l := logrus.WithField("func", "InstanceUpdatePATCHHandler")
authed, err := oauth.Authed(c, true, true, true, true) authed, err := oauth.Authed(c, true, true, true, true)
if err != nil { if err != nil {
l.Debugf("couldn't auth: %s", err) l.Debugf("couldn't auth: %s", err)

View File

@ -21,7 +21,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -37,15 +36,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new list module // New returns a new list module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule { func New(config *config.Config, processor processing.Processor) api.ClientModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }

View File

@ -21,7 +21,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -41,15 +40,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new auth module // New returns a new auth module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule { func New(config *config.Config, processor processing.Processor) api.ClientModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }

View File

@ -21,6 +21,7 @@
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/sirupsen/logrus"
"net/http" "net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -82,7 +83,7 @@
// '422': // '422':
// description: unprocessable // description: unprocessable
func (m *Module) MediaCreatePOSTHandler(c *gin.Context) { func (m *Module) MediaCreatePOSTHandler(c *gin.Context) {
l := m.log.WithField("func", "statusCreatePOSTHandler") l := logrus.WithField("func", "statusCreatePOSTHandler")
authed, err := oauth.Authed(c, true, true, true, true) // posting new media is serious business so we want *everything* authed, err := oauth.Authed(c, true, true, true, true) // posting new media is serious business so we want *everything*
if err != nil { if err != nil {
l.Debugf("couldn't auth: %s", err) l.Debugf("couldn't auth: %s", err)

View File

@ -51,7 +51,6 @@ type MediaCreateTestSuite struct {
suite.Suite suite.Suite
config *config.Config config *config.Config
db db.DB db db.DB
log *logrus.Logger
storage *kv.KVStore storage *kv.KVStore
federator federation.Federator federator federation.Federator
tc typeutils.TypeConverter tc typeutils.TypeConverter
@ -79,7 +78,7 @@ func (suite *MediaCreateTestSuite) SetupSuite() {
// setup standard items // setup standard items
suite.config = testrig.NewTestConfig() suite.config = testrig.NewTestConfig()
suite.db = testrig.NewTestDB() suite.db = testrig.NewTestDB()
suite.log = testrig.NewTestLog() testrig.InitTestLog()
suite.storage = testrig.NewTestStorage() suite.storage = testrig.NewTestStorage()
suite.tc = testrig.NewTestTypeConverter(suite.db) suite.tc = testrig.NewTestTypeConverter(suite.db)
suite.mediaHandler = testrig.NewTestMediaHandler(suite.db, suite.storage) suite.mediaHandler = testrig.NewTestMediaHandler(suite.db, suite.storage)
@ -88,7 +87,7 @@ func (suite *MediaCreateTestSuite) SetupSuite() {
suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator) suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator)
// setup module being tested // setup module being tested
suite.mediaModule = mediamodule.New(suite.config, suite.processor, suite.log).(*mediamodule.Module) suite.mediaModule = mediamodule.New(suite.config, suite.processor).(*mediamodule.Module)
} }
func (suite *MediaCreateTestSuite) TearDownSuite() { func (suite *MediaCreateTestSuite) TearDownSuite() {

View File

@ -19,6 +19,7 @@
package media package media
import ( import (
"github.com/sirupsen/logrus"
"net/http" "net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -61,7 +62,7 @@
// '422': // '422':
// description: unprocessable // description: unprocessable
func (m *Module) MediaGETHandler(c *gin.Context) { func (m *Module) MediaGETHandler(c *gin.Context) {
l := m.log.WithField("func", "MediaGETHandler") l := logrus.WithField("func", "MediaGETHandler")
authed, err := oauth.Authed(c, true, true, true, true) authed, err := oauth.Authed(c, true, true, true, true)
if err != nil { if err != nil {
l.Debugf("couldn't auth: %s", err) l.Debugf("couldn't auth: %s", err)

View File

@ -21,6 +21,7 @@
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/sirupsen/logrus"
"net/http" "net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -91,7 +92,7 @@
// '422': // '422':
// description: unprocessable // description: unprocessable
func (m *Module) MediaPUTHandler(c *gin.Context) { func (m *Module) MediaPUTHandler(c *gin.Context) {
l := m.log.WithField("func", "MediaGETHandler") l := logrus.WithField("func", "MediaGETHandler")
authed, err := oauth.Authed(c, true, true, true, true) authed, err := oauth.Authed(c, true, true, true, true)
if err != nil { if err != nil {
l.Debugf("couldn't auth: %s", err) l.Debugf("couldn't auth: %s", err)

View File

@ -21,7 +21,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -49,15 +48,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new notification module // New returns a new notification module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule { func New(config *config.Config, processor processing.Processor) api.ClientModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }

View File

@ -29,7 +29,7 @@
// NotificationsGETHandler serves a list of notifications to the caller, with the desired query parameters // NotificationsGETHandler serves a list of notifications to the caller, with the desired query parameters
func (m *Module) NotificationsGETHandler(c *gin.Context) { func (m *Module) NotificationsGETHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "NotificationsGETHandler", "func": "NotificationsGETHandler",
"request_uri": c.Request.RequestURI, "request_uri": c.Request.RequestURI,
"user_agent": c.Request.UserAgent(), "user_agent": c.Request.UserAgent(),

View File

@ -21,7 +21,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -68,15 +67,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new search module // New returns a new search module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule { func New(config *config.Config, processor processing.Processor) api.ClientModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }

View File

@ -56,7 +56,7 @@
// '400': // '400':
// description: bad request // description: bad request
func (m *Module) SearchGETHandler(c *gin.Context) { func (m *Module) SearchGETHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "SearchGETHandler", "func": "SearchGETHandler",
"request_uri": c.Request.RequestURI, "request_uri": c.Request.RequestURI,
"user_agent": c.Request.UserAgent(), "user_agent": c.Request.UserAgent(),

View File

@ -19,11 +19,11 @@
package status package status
import ( import (
"github.com/sirupsen/logrus"
"net/http" "net/http"
"strings" "strings"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -76,15 +76,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new account module // New returns a new account module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule { func New(config *config.Config, processor processing.Processor) api.ClientModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }
@ -109,7 +107,7 @@ func (m *Module) Route(r router.Router) error {
// muxHandler is a little workaround to overcome the limitations of Gin // muxHandler is a little workaround to overcome the limitations of Gin
func (m *Module) muxHandler(c *gin.Context) { func (m *Module) muxHandler(c *gin.Context) {
m.log.Debug("entering mux handler") logrus.Debug("entering mux handler")
ru := c.Request.RequestURI ru := c.Request.RequestURI
switch c.Request.Method { switch c.Request.Method {

View File

@ -20,7 +20,6 @@
import ( import (
"git.iim.gay/grufwub/go-store/kv" "git.iim.gay/grufwub/go-store/kv"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/api/client/status" "github.com/superseriousbusiness/gotosocial/internal/api/client/status"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
@ -37,7 +36,6 @@ type StatusStandardTestSuite struct {
suite.Suite suite.Suite
config *config.Config config *config.Config
db db.DB db db.DB
log *logrus.Logger
tc typeutils.TypeConverter tc typeutils.TypeConverter
federator federation.Federator federator federation.Federator
processor processing.Processor processor processing.Processor

View File

@ -66,7 +66,7 @@
// '404': // '404':
// description: not found // description: not found
func (m *Module) StatusBoostPOSTHandler(c *gin.Context) { func (m *Module) StatusBoostPOSTHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "StatusBoostPOSTHandler", "func": "StatusBoostPOSTHandler",
"request_uri": c.Request.RequestURI, "request_uri": c.Request.RequestURI,
"user_agent": c.Request.UserAgent(), "user_agent": c.Request.UserAgent(),

View File

@ -51,10 +51,10 @@ func (suite *StatusBoostTestSuite) SetupTest() {
suite.config = testrig.NewTestConfig() suite.config = testrig.NewTestConfig()
suite.db = testrig.NewTestDB() suite.db = testrig.NewTestDB()
suite.storage = testrig.NewTestStorage() suite.storage = testrig.NewTestStorage()
suite.log = testrig.NewTestLog() testrig.InitTestLog()
suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage) suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator) suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator)
suite.statusModule = status.New(suite.config, suite.processor, suite.log).(*status.Module) suite.statusModule = status.New(suite.config, suite.processor).(*status.Module)
testrig.StandardDBSetup(suite.db, nil) testrig.StandardDBSetup(suite.db, nil)
testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media") testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media")
} }

View File

@ -63,7 +63,7 @@
// '404': // '404':
// description: not found // description: not found
func (m *Module) StatusBoostedByGETHandler(c *gin.Context) { func (m *Module) StatusBoostedByGETHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "StatusBoostedByGETHandler", "func": "StatusBoostedByGETHandler",
"request_uri": c.Request.RequestURI, "request_uri": c.Request.RequestURI,
"user_agent": c.Request.UserAgent(), "user_agent": c.Request.UserAgent(),

View File

@ -65,7 +65,7 @@
// '404': // '404':
// description: not found // description: not found
func (m *Module) StatusContextGETHandler(c *gin.Context) { func (m *Module) StatusContextGETHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "StatusContextGETHandler", "func": "StatusContextGETHandler",
"request_uri": c.Request.RequestURI, "request_uri": c.Request.RequestURI,
"user_agent": c.Request.UserAgent(), "user_agent": c.Request.UserAgent(),

View File

@ -21,6 +21,7 @@
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/sirupsen/logrus"
"net/http" "net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
@ -67,7 +68,7 @@
// '500': // '500':
// description: internal error // description: internal error
func (m *Module) StatusCreatePOSTHandler(c *gin.Context) { func (m *Module) StatusCreatePOSTHandler(c *gin.Context) {
l := m.log.WithField("func", "statusCreatePOSTHandler") l := logrus.WithField("func", "statusCreatePOSTHandler")
authed, err := oauth.Authed(c, true, true, true, true) // posting a status is serious business so we want *everything* authed, err := oauth.Authed(c, true, true, true, true) // posting a status is serious business so we want *everything*
if err != nil { if err != nil {
l.Debugf("couldn't auth: %s", err) l.Debugf("couldn't auth: %s", err)

View File

@ -57,11 +57,11 @@ func (suite *StatusCreateTestSuite) SetupTest() {
suite.config = testrig.NewTestConfig() suite.config = testrig.NewTestConfig()
suite.db = testrig.NewTestDB() suite.db = testrig.NewTestDB()
suite.storage = testrig.NewTestStorage() suite.storage = testrig.NewTestStorage()
suite.log = testrig.NewTestLog() testrig.InitTestLog()
suite.tc = testrig.NewTestTypeConverter(suite.db) suite.tc = testrig.NewTestTypeConverter(suite.db)
suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage) suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator) suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator)
suite.statusModule = status.New(suite.config, suite.processor, suite.log).(*status.Module) suite.statusModule = status.New(suite.config, suite.processor).(*status.Module)
testrig.StandardDBSetup(suite.db, nil) testrig.StandardDBSetup(suite.db, nil)
testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media") testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media")
} }

View File

@ -65,7 +65,7 @@
// '404': // '404':
// description: not found // description: not found
func (m *Module) StatusDELETEHandler(c *gin.Context) { func (m *Module) StatusDELETEHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "StatusDELETEHandler", "func": "StatusDELETEHandler",
"request_uri": c.Request.RequestURI, "request_uri": c.Request.RequestURI,
"user_agent": c.Request.UserAgent(), "user_agent": c.Request.UserAgent(),

View File

@ -62,7 +62,7 @@
// '404': // '404':
// description: not found // description: not found
func (m *Module) StatusFavePOSTHandler(c *gin.Context) { func (m *Module) StatusFavePOSTHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "StatusFavePOSTHandler", "func": "StatusFavePOSTHandler",
"request_uri": c.Request.RequestURI, "request_uri": c.Request.RequestURI,
"user_agent": c.Request.UserAgent(), "user_agent": c.Request.UserAgent(),

View File

@ -54,10 +54,10 @@ func (suite *StatusFaveTestSuite) SetupTest() {
suite.config = testrig.NewTestConfig() suite.config = testrig.NewTestConfig()
suite.db = testrig.NewTestDB() suite.db = testrig.NewTestDB()
suite.storage = testrig.NewTestStorage() suite.storage = testrig.NewTestStorage()
suite.log = testrig.NewTestLog() testrig.InitTestLog()
suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage) suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator) suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator)
suite.statusModule = status.New(suite.config, suite.processor, suite.log).(*status.Module) suite.statusModule = status.New(suite.config, suite.processor).(*status.Module)
testrig.StandardDBSetup(suite.db, nil) testrig.StandardDBSetup(suite.db, nil)
testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media") testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media")
} }

View File

@ -63,7 +63,7 @@
// '404': // '404':
// description: not found // description: not found
func (m *Module) StatusFavedByGETHandler(c *gin.Context) { func (m *Module) StatusFavedByGETHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "statusGETHandler", "func": "statusGETHandler",
"request_uri": c.Request.RequestURI, "request_uri": c.Request.RequestURI,
"user_agent": c.Request.UserAgent(), "user_agent": c.Request.UserAgent(),

View File

@ -54,10 +54,10 @@ func (suite *StatusFavedByTestSuite) SetupTest() {
suite.config = testrig.NewTestConfig() suite.config = testrig.NewTestConfig()
suite.db = testrig.NewTestDB() suite.db = testrig.NewTestDB()
suite.storage = testrig.NewTestStorage() suite.storage = testrig.NewTestStorage()
suite.log = testrig.NewTestLog() testrig.InitTestLog()
suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage) suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator) suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator)
suite.statusModule = status.New(suite.config, suite.processor, suite.log).(*status.Module) suite.statusModule = status.New(suite.config, suite.processor).(*status.Module)
testrig.StandardDBSetup(suite.db, nil) testrig.StandardDBSetup(suite.db, nil)
testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media") testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media")
} }

View File

@ -62,7 +62,7 @@
// '500': // '500':
// description: internal error // description: internal error
func (m *Module) StatusGETHandler(c *gin.Context) { func (m *Module) StatusGETHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "statusGETHandler", "func": "statusGETHandler",
"request_uri": c.Request.RequestURI, "request_uri": c.Request.RequestURI,
"user_agent": c.Request.UserAgent(), "user_agent": c.Request.UserAgent(),

View File

@ -44,10 +44,10 @@ func (suite *StatusGetTestSuite) SetupTest() {
suite.config = testrig.NewTestConfig() suite.config = testrig.NewTestConfig()
suite.db = testrig.NewTestDB() suite.db = testrig.NewTestDB()
suite.storage = testrig.NewTestStorage() suite.storage = testrig.NewTestStorage()
suite.log = testrig.NewTestLog() testrig.InitTestLog()
suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage) suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator) suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator)
suite.statusModule = status.New(suite.config, suite.processor, suite.log).(*status.Module) suite.statusModule = status.New(suite.config, suite.processor).(*status.Module)
testrig.StandardDBSetup(suite.db, nil) testrig.StandardDBSetup(suite.db, nil)
testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media") testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media")
} }

View File

@ -63,7 +63,7 @@
// '404': // '404':
// description: not found // description: not found
func (m *Module) StatusUnboostPOSTHandler(c *gin.Context) { func (m *Module) StatusUnboostPOSTHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "StatusUnboostPOSTHandler", "func": "StatusUnboostPOSTHandler",
"request_uri": c.Request.RequestURI, "request_uri": c.Request.RequestURI,
"user_agent": c.Request.UserAgent(), "user_agent": c.Request.UserAgent(),

View File

@ -62,7 +62,7 @@
// '404': // '404':
// description: not found // description: not found
func (m *Module) StatusUnfavePOSTHandler(c *gin.Context) { func (m *Module) StatusUnfavePOSTHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "StatusUnfavePOSTHandler", "func": "StatusUnfavePOSTHandler",
"request_uri": c.Request.RequestURI, "request_uri": c.Request.RequestURI,
"user_agent": c.Request.UserAgent(), "user_agent": c.Request.UserAgent(),

View File

@ -54,10 +54,10 @@ func (suite *StatusUnfaveTestSuite) SetupTest() {
suite.config = testrig.NewTestConfig() suite.config = testrig.NewTestConfig()
suite.db = testrig.NewTestDB() suite.db = testrig.NewTestDB()
suite.storage = testrig.NewTestStorage() suite.storage = testrig.NewTestStorage()
suite.log = testrig.NewTestLog() testrig.InitTestLog()
suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage) suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator) suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator)
suite.statusModule = status.New(suite.config, suite.processor, suite.log).(*status.Module) suite.statusModule = status.New(suite.config, suite.processor).(*status.Module)
testrig.StandardDBSetup(suite.db, nil) testrig.StandardDBSetup(suite.db, nil)
testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media") testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media")
} }

View File

@ -2,6 +2,7 @@
import ( import (
"fmt" "fmt"
"github.com/sirupsen/logrus"
"net/http" "net/http"
"time" "time"
@ -107,7 +108,7 @@
// '400': // '400':
// description: bad request // description: bad request
func (m *Module) StreamGETHandler(c *gin.Context) { func (m *Module) StreamGETHandler(c *gin.Context) {
l := m.log.WithField("func", "StreamGETHandler") l := logrus.WithField("func", "StreamGETHandler")
streamType := c.Query(StreamQueryKey) streamType := c.Query(StreamQueryKey)
if streamType == "" { if streamType == "" {

View File

@ -21,7 +21,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -43,15 +42,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new streaming module // New returns a new streaming module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule { func New(config *config.Config, processor processing.Processor) api.ClientModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }

View File

@ -19,6 +19,7 @@
package timeline package timeline
import ( import (
"github.com/sirupsen/logrus"
"net/http" "net/http"
"strconv" "strconv"
@ -102,7 +103,7 @@
// '400': // '400':
// description: bad request // description: bad request
func (m *Module) HomeTimelineGETHandler(c *gin.Context) { func (m *Module) HomeTimelineGETHandler(c *gin.Context) {
l := m.log.WithField("func", "HomeTimelineGETHandler") l := logrus.WithField("func", "HomeTimelineGETHandler")
authed, err := oauth.Authed(c, true, true, true, true) authed, err := oauth.Authed(c, true, true, true, true)
if err != nil { if err != nil {

View File

@ -19,6 +19,7 @@
package timeline package timeline
import ( import (
"github.com/sirupsen/logrus"
"net/http" "net/http"
"strconv" "strconv"
@ -102,7 +103,7 @@
// '400': // '400':
// description: bad request // description: bad request
func (m *Module) PublicTimelineGETHandler(c *gin.Context) { func (m *Module) PublicTimelineGETHandler(c *gin.Context) {
l := m.log.WithField("func", "PublicTimelineGETHandler") l := logrus.WithField("func", "PublicTimelineGETHandler")
authed, err := oauth.Authed(c, true, true, true, true) authed, err := oauth.Authed(c, true, true, true, true)
if err != nil { if err != nil {

View File

@ -21,7 +21,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -51,15 +50,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new timeline module // New returns a new timeline module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule { func New(config *config.Config, processor processing.Processor) api.ClientModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }

View File

@ -21,7 +21,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -39,15 +38,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new nodeinfo module // New returns a new nodeinfo module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.FederationModule { func New(config *config.Config, processor processing.Processor) api.FederationModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }

View File

@ -28,7 +28,7 @@
// NodeInfoGETHandler returns a compliant nodeinfo response to node info queries. // NodeInfoGETHandler returns a compliant nodeinfo response to node info queries.
// See: https://nodeinfo.diaspora.software/ // See: https://nodeinfo.diaspora.software/
func (m *Module) NodeInfoGETHandler(c *gin.Context) { func (m *Module) NodeInfoGETHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "NodeInfoGETHandler", "func": "NodeInfoGETHandler",
"user-agent": c.Request.UserAgent(), "user-agent": c.Request.UserAgent(),
}) })

View File

@ -28,7 +28,7 @@
// NodeInfoWellKnownGETHandler returns a well known response to a query to /.well-known/nodeinfo, // NodeInfoWellKnownGETHandler returns a well known response to a query to /.well-known/nodeinfo,
// directing (but not redirecting...) callers to the NodeInfoGETHandler. // directing (but not redirecting...) callers to the NodeInfoGETHandler.
func (m *Module) NodeInfoWellKnownGETHandler(c *gin.Context) { func (m *Module) NodeInfoWellKnownGETHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "NodeInfoWellKnownGETHandler", "func": "NodeInfoWellKnownGETHandler",
"user-agent": c.Request.UserAgent(), "user-agent": c.Request.UserAgent(),
}) })

View File

@ -29,7 +29,7 @@
// FollowersGETHandler returns a collection of URIs for followers of the target user, formatted so that other AP servers can understand it. // FollowersGETHandler returns a collection of URIs for followers of the target user, formatted so that other AP servers can understand it.
func (m *Module) FollowersGETHandler(c *gin.Context) { func (m *Module) FollowersGETHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "FollowersGETHandler", "func": "FollowersGETHandler",
"url": c.Request.RequestURI, "url": c.Request.RequestURI,
}) })

View File

@ -29,7 +29,7 @@
// FollowingGETHandler returns a collection of URIs for accounts that the target user follows, formatted so that other AP servers can understand it. // FollowingGETHandler returns a collection of URIs for accounts that the target user follows, formatted so that other AP servers can understand it.
func (m *Module) FollowingGETHandler(c *gin.Context) { func (m *Module) FollowingGETHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "FollowingGETHandler", "func": "FollowingGETHandler",
"url": c.Request.RequestURI, "url": c.Request.RequestURI,
}) })

View File

@ -29,7 +29,7 @@
// InboxPOSTHandler deals with incoming POST requests to an actor's inbox. // InboxPOSTHandler deals with incoming POST requests to an actor's inbox.
// Eg., POST to https://example.org/users/whatever/inbox. // Eg., POST to https://example.org/users/whatever/inbox.
func (m *Module) InboxPOSTHandler(c *gin.Context) { func (m *Module) InboxPOSTHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "InboxPOSTHandler", "func": "InboxPOSTHandler",
"url": c.Request.RequestURI, "url": c.Request.RequestURI,
}) })

View File

@ -86,7 +86,7 @@ func (suite *InboxPostTestSuite) TestPostBlock() {
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db) tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
federator := testrig.NewTestFederator(suite.db, tc, suite.storage) federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
processor := testrig.NewTestProcessor(suite.db, suite.storage, federator) processor := testrig.NewTestProcessor(suite.db, suite.storage, federator)
userModule := user.New(suite.config, processor, suite.log).(*user.Module) userModule := user.New(suite.config, processor).(*user.Module)
// setup request // setup request
recorder := httptest.NewRecorder() recorder := httptest.NewRecorder()
@ -185,7 +185,7 @@ func (suite *InboxPostTestSuite) TestPostUnblock() {
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db) tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
federator := testrig.NewTestFederator(suite.db, tc, suite.storage) federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
processor := testrig.NewTestProcessor(suite.db, suite.storage, federator) processor := testrig.NewTestProcessor(suite.db, suite.storage, federator)
userModule := user.New(suite.config, processor, suite.log).(*user.Module) userModule := user.New(suite.config, processor).(*user.Module)
// setup request // setup request
recorder := httptest.NewRecorder() recorder := httptest.NewRecorder()
@ -274,7 +274,7 @@ func (suite *InboxPostTestSuite) TestPostUpdate() {
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db) tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
federator := testrig.NewTestFederator(suite.db, tc, suite.storage) federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
processor := testrig.NewTestProcessor(suite.db, suite.storage, federator) processor := testrig.NewTestProcessor(suite.db, suite.storage, federator)
userModule := user.New(suite.config, processor, suite.log).(*user.Module) userModule := user.New(suite.config, processor).(*user.Module)
// setup request // setup request
recorder := httptest.NewRecorder() recorder := httptest.NewRecorder()
@ -394,7 +394,7 @@ func (suite *InboxPostTestSuite) TestPostDelete() {
processor := testrig.NewTestProcessor(suite.db, suite.storage, federator) processor := testrig.NewTestProcessor(suite.db, suite.storage, federator)
err = processor.Start(context.Background()) err = processor.Start(context.Background())
suite.NoError(err) suite.NoError(err)
userModule := user.New(suite.config, processor, suite.log).(*user.Module) userModule := user.New(suite.config, processor).(*user.Module)
// setup request // setup request
recorder := httptest.NewRecorder() recorder := httptest.NewRecorder()

View File

@ -33,7 +33,7 @@
// in the form of a vocab.ActivityStreamsPerson. The account will only contain the id, // in the form of a vocab.ActivityStreamsPerson. The account will only contain the id,
// public key, username, and type of the account. // public key, username, and type of the account.
func (m *Module) PublicKeyGETHandler(c *gin.Context) { func (m *Module) PublicKeyGETHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "PublicKeyGETHandler", "func": "PublicKeyGETHandler",
"url": c.Request.RequestURI, "url": c.Request.RequestURI,
}) })

View File

@ -85,7 +85,7 @@
// '404': // '404':
// description: not found // description: not found
func (m *Module) StatusRepliesGETHandler(c *gin.Context) { func (m *Module) StatusRepliesGETHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "StatusRepliesGETHandler", "func": "StatusRepliesGETHandler",
"url": c.Request.RequestURI, "url": c.Request.RequestURI,
}) })

View File

@ -50,7 +50,7 @@ func (suite *RepliesGetTestSuite) TestGetReplies() {
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db) tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
federator := testrig.NewTestFederator(suite.db, tc, suite.storage) federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
processor := testrig.NewTestProcessor(suite.db, suite.storage, federator) processor := testrig.NewTestProcessor(suite.db, suite.storage, federator)
userModule := user.New(suite.config, processor, suite.log).(*user.Module) userModule := user.New(suite.config, processor).(*user.Module)
// setup request // setup request
recorder := httptest.NewRecorder() recorder := httptest.NewRecorder()
@ -109,7 +109,7 @@ func (suite *RepliesGetTestSuite) TestGetRepliesNext() {
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db) tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
federator := testrig.NewTestFederator(suite.db, tc, suite.storage) federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
processor := testrig.NewTestProcessor(suite.db, suite.storage, federator) processor := testrig.NewTestProcessor(suite.db, suite.storage, federator)
userModule := user.New(suite.config, processor, suite.log).(*user.Module) userModule := user.New(suite.config, processor).(*user.Module)
// setup request // setup request
recorder := httptest.NewRecorder() recorder := httptest.NewRecorder()
@ -171,7 +171,7 @@ func (suite *RepliesGetTestSuite) TestGetRepliesLast() {
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db) tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
federator := testrig.NewTestFederator(suite.db, tc, suite.storage) federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
processor := testrig.NewTestProcessor(suite.db, suite.storage, federator) processor := testrig.NewTestProcessor(suite.db, suite.storage, federator)
userModule := user.New(suite.config, processor, suite.log).(*user.Module) userModule := user.New(suite.config, processor).(*user.Module)
// setup request // setup request
recorder := httptest.NewRecorder() recorder := httptest.NewRecorder()

View File

@ -29,7 +29,7 @@
// StatusGETHandler serves the target status as an activitystreams NOTE so that other AP servers can parse it. // StatusGETHandler serves the target status as an activitystreams NOTE so that other AP servers can parse it.
func (m *Module) StatusGETHandler(c *gin.Context) { func (m *Module) StatusGETHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "StatusGETHandler", "func": "StatusGETHandler",
"url": c.Request.RequestURI, "url": c.Request.RequestURI,
}) })

View File

@ -21,7 +21,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -65,15 +64,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new auth module // New returns a new auth module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.FederationModule { func New(config *config.Config, processor processing.Processor) api.FederationModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }

View File

@ -20,7 +20,6 @@
import ( import (
"git.iim.gay/grufwub/go-store/kv" "git.iim.gay/grufwub/go-store/kv"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/api/s2s/user" "github.com/superseriousbusiness/gotosocial/internal/api/s2s/user"
"github.com/superseriousbusiness/gotosocial/internal/api/security" "github.com/superseriousbusiness/gotosocial/internal/api/security"
@ -38,7 +37,6 @@ type UserStandardTestSuite struct {
suite.Suite suite.Suite
config *config.Config config *config.Config
db db.DB db db.DB
log *logrus.Logger
tc typeutils.TypeConverter tc typeutils.TypeConverter
federator federation.Federator federator federation.Federator
processor processing.Processor processor processing.Processor
@ -75,11 +73,11 @@ func (suite *UserStandardTestSuite) SetupTest() {
suite.db = testrig.NewTestDB() suite.db = testrig.NewTestDB()
suite.tc = testrig.NewTestTypeConverter(suite.db) suite.tc = testrig.NewTestTypeConverter(suite.db)
suite.storage = testrig.NewTestStorage() suite.storage = testrig.NewTestStorage()
suite.log = testrig.NewTestLog() testrig.InitTestLog()
suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage) suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator) suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator)
suite.userModule = user.New(suite.config, suite.processor, suite.log).(*user.Module) suite.userModule = user.New(suite.config, suite.processor).(*user.Module)
suite.securityModule = security.New(suite.config, suite.db, suite.log).(*security.Module) suite.securityModule = security.New(suite.config, suite.db).(*security.Module)
testrig.StandardDBSetup(suite.db, suite.testAccounts) testrig.StandardDBSetup(suite.db, suite.testAccounts)
testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media") testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media")
} }

View File

@ -37,7 +37,7 @@
// And of course, the request should be refused if the account or server making the // And of course, the request should be refused if the account or server making the
// request is blocked. // request is blocked.
func (m *Module) UsersGETHandler(c *gin.Context) { func (m *Module) UsersGETHandler(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "UsersGETHandler", "func": "UsersGETHandler",
"url": c.Request.RequestURI, "url": c.Request.RequestURI,
}) })

View File

@ -48,7 +48,7 @@ func (suite *UserGetTestSuite) TestGetUser() {
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db) tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
federator := testrig.NewTestFederator(suite.db, tc, suite.storage) federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
processor := testrig.NewTestProcessor(suite.db, suite.storage, federator) processor := testrig.NewTestProcessor(suite.db, suite.storage, federator)
userModule := user.New(suite.config, processor, suite.log).(*user.Module) userModule := user.New(suite.config, processor).(*user.Module)
// setup request // setup request
recorder := httptest.NewRecorder() recorder := httptest.NewRecorder()

View File

@ -21,7 +21,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/processing"
@ -37,15 +36,13 @@
type Module struct { type Module struct {
config *config.Config config *config.Config
processor processing.Processor processor processing.Processor
log *logrus.Logger
} }
// New returns a new webfinger module // New returns a new webfinger module
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.FederationModule { func New(config *config.Config, processor processing.Processor) api.FederationModule {
return &Module{ return &Module{
config: config, config: config,
processor: processor, processor: processor,
log: log,
} }
} }

View File

@ -24,7 +24,6 @@
"time" "time"
"git.iim.gay/grufwub/go-store/kv" "git.iim.gay/grufwub/go-store/kv"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/ap" "github.com/superseriousbusiness/gotosocial/internal/ap"
"github.com/superseriousbusiness/gotosocial/internal/api/s2s/webfinger" "github.com/superseriousbusiness/gotosocial/internal/api/s2s/webfinger"
@ -43,7 +42,6 @@ type WebfingerStandardTestSuite struct {
suite.Suite suite.Suite
config *config.Config config *config.Config
db db.DB db db.DB
log *logrus.Logger
tc typeutils.TypeConverter tc typeutils.TypeConverter
federator federation.Federator federator federation.Federator
processor processing.Processor processor processing.Processor
@ -78,11 +76,11 @@ func (suite *WebfingerStandardTestSuite) SetupTest() {
suite.db = testrig.NewTestDB() suite.db = testrig.NewTestDB()
suite.tc = testrig.NewTestTypeConverter(suite.db) suite.tc = testrig.NewTestTypeConverter(suite.db)
suite.storage = testrig.NewTestStorage() suite.storage = testrig.NewTestStorage()
suite.log = testrig.NewTestLog() testrig.InitTestLog()
suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage) suite.federator = testrig.NewTestFederator(suite.db, testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db), suite.storage)
suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator) suite.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator)
suite.webfingerModule = webfinger.New(suite.config, suite.processor, suite.log).(*webfinger.Module) suite.webfingerModule = webfinger.New(suite.config, suite.processor).(*webfinger.Module)
suite.securityModule = security.New(suite.config, suite.db, suite.log).(*security.Module) suite.securityModule = security.New(suite.config, suite.db).(*security.Module)
testrig.StandardDBSetup(suite.db, suite.testAccounts) testrig.StandardDBSetup(suite.db, suite.testAccounts)
testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media") testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media")
} }

View File

@ -31,7 +31,7 @@
// WebfingerGETRequest handles requests to, for example, https://example.org/.well-known/webfinger?resource=acct:some_user@example.org // WebfingerGETRequest handles requests to, for example, https://example.org/.well-known/webfinger?resource=acct:some_user@example.org
func (m *Module) WebfingerGETRequest(c *gin.Context) { func (m *Module) WebfingerGETRequest(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "WebfingerGETRequest", "func": "WebfingerGETRequest",
"user-agent": c.Request.UserAgent(), "user-agent": c.Request.UserAgent(),
}) })

View File

@ -65,8 +65,8 @@ func (suite *WebfingerGetTestSuite) TestFingerUser() {
func (suite *WebfingerGetTestSuite) TestFingerUserWithDifferentAccountDomainByHost() { func (suite *WebfingerGetTestSuite) TestFingerUserWithDifferentAccountDomainByHost() {
suite.config.Host = "gts.example.org" suite.config.Host = "gts.example.org"
suite.config.AccountDomain = "example.org" suite.config.AccountDomain = "example.org"
suite.processor = processing.NewProcessor(suite.config, suite.tc, suite.federator, testrig.NewTestOauthServer(suite.db), testrig.NewTestMediaHandler(suite.db, suite.storage), suite.storage, testrig.NewTestTimelineManager(suite.db), suite.db, suite.log) suite.processor = processing.NewProcessor(suite.config, suite.tc, suite.federator, testrig.NewTestOauthServer(suite.db), testrig.NewTestMediaHandler(suite.db, suite.storage), suite.storage, testrig.NewTestTimelineManager(suite.db), suite.db)
suite.webfingerModule = webfinger.New(suite.config, suite.processor, suite.log).(*webfinger.Module) suite.webfingerModule = webfinger.New(suite.config, suite.processor).(*webfinger.Module)
targetAccount := accountDomainAccount() targetAccount := accountDomainAccount()
if err := suite.db.Put(context.Background(), targetAccount); err != nil { if err := suite.db.Put(context.Background(), targetAccount); err != nil {
@ -97,8 +97,8 @@ func (suite *WebfingerGetTestSuite) TestFingerUserWithDifferentAccountDomainByHo
func (suite *WebfingerGetTestSuite) TestFingerUserWithDifferentAccountDomainByAccountDomain() { func (suite *WebfingerGetTestSuite) TestFingerUserWithDifferentAccountDomainByAccountDomain() {
suite.config.Host = "gts.example.org" suite.config.Host = "gts.example.org"
suite.config.AccountDomain = "example.org" suite.config.AccountDomain = "example.org"
suite.processor = processing.NewProcessor(suite.config, suite.tc, suite.federator, testrig.NewTestOauthServer(suite.db), testrig.NewTestMediaHandler(suite.db, suite.storage), suite.storage, testrig.NewTestTimelineManager(suite.db), suite.db, suite.log) suite.processor = processing.NewProcessor(suite.config, suite.tc, suite.federator, testrig.NewTestOauthServer(suite.db), testrig.NewTestMediaHandler(suite.db, suite.storage), suite.storage, testrig.NewTestTimelineManager(suite.db), suite.db)
suite.webfingerModule = webfinger.New(suite.config, suite.processor, suite.log).(*webfinger.Module) suite.webfingerModule = webfinger.New(suite.config, suite.processor).(*webfinger.Module)
targetAccount := accountDomainAccount() targetAccount := accountDomainAccount()
if err := suite.db.Put(context.Background(), targetAccount); err != nil { if err := suite.db.Put(context.Background(), targetAccount); err != nil {

View File

@ -21,7 +21,6 @@
import ( import (
"net/http" "net/http"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api" "github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/db"
@ -33,15 +32,13 @@
// Module implements the ClientAPIModule interface for security middleware // Module implements the ClientAPIModule interface for security middleware
type Module struct { type Module struct {
config *config.Config config *config.Config
log *logrus.Logger
db db.DB db db.DB
} }
// New returns a new security module // New returns a new security module
func New(config *config.Config, db db.DB, log *logrus.Logger) api.ClientModule { func New(config *config.Config, db db.DB) api.ClientModule {
return &Module{ return &Module{
config: config, config: config,
log: log,
db: db, db: db,
} }
} }

View File

@ -1,6 +1,7 @@
package security package security
import ( import (
"github.com/sirupsen/logrus"
"net/http" "net/http"
"net/url" "net/url"
@ -13,7 +14,7 @@
// that signed the request is permitted to access the server. If it is permitted, the handler will set the key // that signed the request is permitted to access the server. If it is permitted, the handler will set the key
// verifier and the signature in the gin context for use down the line. // verifier and the signature in the gin context for use down the line.
func (m *Module) SignatureCheck(c *gin.Context) { func (m *Module) SignatureCheck(c *gin.Context) {
l := m.log.WithField("func", "DomainBlockChecker") l := logrus.WithField("func", "DomainBlockChecker")
// create the verifier from the request // create the verifier from the request
// if the request is signed, it will have a signature header // if the request is signed, it will have a signature header

View File

@ -27,7 +27,7 @@
// UserAgentBlock blocks requests with undesired, empty, or invalid user-agent strings. // UserAgentBlock blocks requests with undesired, empty, or invalid user-agent strings.
func (m *Module) UserAgentBlock(c *gin.Context) { func (m *Module) UserAgentBlock(c *gin.Context) {
l := m.log.WithFields(logrus.Fields{ l := logrus.WithFields(logrus.Fields{
"func": "UserAgentBlock", "func": "UserAgentBlock",
}) })

View File

@ -21,11 +21,10 @@
import ( import (
"context" "context"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
) )
// GTSAction defines one *action* that can be taken by the gotosocial cli command. // GTSAction defines one *action* that can be taken by the gotosocial cli command.
// This can be either a long-running action (like server start) or something // This can be either a long-running action (like server start) or something
// shorter like db init or db inspect. // shorter like db init or db inspect.
type GTSAction func(context.Context, *config.Config, *logrus.Logger) error type GTSAction func(context.Context, *config.Config) error

View File

@ -24,7 +24,6 @@
"fmt" "fmt"
"time" "time"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/cliactions" "github.com/superseriousbusiness/gotosocial/internal/cliactions"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/db"
@ -35,8 +34,8 @@
) )
// Create creates a new account in the database using the provided flags. // Create creates a new account in the database using the provided flags.
var Create cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { var Create cliactions.GTSAction = func(ctx context.Context, c *config.Config) error {
dbConn, err := bundb.NewBunDBService(ctx, c, log) dbConn, err := bundb.NewBunDBService(ctx, c)
if err != nil { if err != nil {
return fmt.Errorf("error creating dbservice: %s", err) return fmt.Errorf("error creating dbservice: %s", err)
} }
@ -74,8 +73,8 @@
} }
// Confirm sets a user to Approved, sets Email to the current UnconfirmedEmail value, and sets ConfirmedAt to now. // Confirm sets a user to Approved, sets Email to the current UnconfirmedEmail value, and sets ConfirmedAt to now.
var Confirm cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { var Confirm cliactions.GTSAction = func(ctx context.Context, c *config.Config) error {
dbConn, err := bundb.NewBunDBService(ctx, c, log) dbConn, err := bundb.NewBunDBService(ctx, c)
if err != nil { if err != nil {
return fmt.Errorf("error creating dbservice: %s", err) return fmt.Errorf("error creating dbservice: %s", err)
} }
@ -109,8 +108,8 @@
} }
// Promote sets a user to admin. // Promote sets a user to admin.
var Promote cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { var Promote cliactions.GTSAction = func(ctx context.Context, c *config.Config) error {
dbConn, err := bundb.NewBunDBService(ctx, c, log) dbConn, err := bundb.NewBunDBService(ctx, c)
if err != nil { if err != nil {
return fmt.Errorf("error creating dbservice: %s", err) return fmt.Errorf("error creating dbservice: %s", err)
} }
@ -141,8 +140,8 @@
} }
// Demote sets admin on a user to false. // Demote sets admin on a user to false.
var Demote cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { var Demote cliactions.GTSAction = func(ctx context.Context, c *config.Config) error {
dbConn, err := bundb.NewBunDBService(ctx, c, log) dbConn, err := bundb.NewBunDBService(ctx, c)
if err != nil { if err != nil {
return fmt.Errorf("error creating dbservice: %s", err) return fmt.Errorf("error creating dbservice: %s", err)
} }
@ -173,8 +172,8 @@
} }
// Disable sets Disabled to true on a user. // Disable sets Disabled to true on a user.
var Disable cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { var Disable cliactions.GTSAction = func(ctx context.Context, c *config.Config) error {
dbConn, err := bundb.NewBunDBService(ctx, c, log) dbConn, err := bundb.NewBunDBService(ctx, c)
if err != nil { if err != nil {
return fmt.Errorf("error creating dbservice: %s", err) return fmt.Errorf("error creating dbservice: %s", err)
} }
@ -205,14 +204,14 @@
} }
// Suspend suspends the target account, cleanly removing all of its media, followers, following, likes, statuses, etc. // Suspend suspends the target account, cleanly removing all of its media, followers, following, likes, statuses, etc.
var Suspend cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { var Suspend cliactions.GTSAction = func(ctx context.Context, c *config.Config) error {
// TODO // TODO
return nil return nil
} }
// Password sets the password of target account. // Password sets the password of target account.
var Password cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { var Password cliactions.GTSAction = func(ctx context.Context, c *config.Config) error {
dbConn, err := bundb.NewBunDBService(ctx, c, log) dbConn, err := bundb.NewBunDBService(ctx, c)
if err != nil { if err != nil {
return fmt.Errorf("error creating dbservice: %s", err) return fmt.Errorf("error creating dbservice: %s", err)
} }

View File

@ -23,7 +23,6 @@
"errors" "errors"
"fmt" "fmt"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/cliactions" "github.com/superseriousbusiness/gotosocial/internal/cliactions"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db/bundb" "github.com/superseriousbusiness/gotosocial/internal/db/bundb"
@ -31,13 +30,13 @@
) )
// Export exports info from the database into a file // Export exports info from the database into a file
var Export cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { var Export cliactions.GTSAction = func(ctx context.Context, c *config.Config) error {
dbConn, err := bundb.NewBunDBService(ctx, c, log) dbConn, err := bundb.NewBunDBService(ctx, c)
if err != nil { if err != nil {
return fmt.Errorf("error creating dbservice: %s", err) return fmt.Errorf("error creating dbservice: %s", err)
} }
exporter := trans.NewExporter(dbConn, log) exporter := trans.NewExporter(dbConn)
path, ok := c.ExportCLIFlags[config.TransPathFlag] path, ok := c.ExportCLIFlags[config.TransPathFlag]
if !ok { if !ok {

View File

@ -23,7 +23,6 @@
"errors" "errors"
"fmt" "fmt"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/cliactions" "github.com/superseriousbusiness/gotosocial/internal/cliactions"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db/bundb" "github.com/superseriousbusiness/gotosocial/internal/db/bundb"
@ -31,13 +30,13 @@
) )
// Import imports info from a file into the database // Import imports info from a file into the database
var Import cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { var Import cliactions.GTSAction = func(ctx context.Context, c *config.Config) error {
dbConn, err := bundb.NewBunDBService(ctx, c, log) dbConn, err := bundb.NewBunDBService(ctx, c)
if err != nil { if err != nil {
return fmt.Errorf("error creating dbservice: %s", err) return fmt.Errorf("error creating dbservice: %s", err)
} }
importer := trans.NewImporter(dbConn, log) importer := trans.NewImporter(dbConn)
path, ok := c.ExportCLIFlags[config.TransPathFlag] path, ok := c.ExportCLIFlags[config.TransPathFlag]
if !ok { if !ok {

View File

@ -51,8 +51,8 @@
) )
// Start creates and starts a gotosocial server // Start creates and starts a gotosocial server
var Start cliactions.GTSAction = func(ctx context.Context, c *config.Config, log *logrus.Logger) error { var Start cliactions.GTSAction = func(ctx context.Context, c *config.Config) error {
dbService, err := bundb.NewBunDBService(ctx, c, log) dbService, err := bundb.NewBunDBService(ctx, c)
if err != nil { if err != nil {
return fmt.Errorf("error creating dbservice: %s", err) return fmt.Errorf("error creating dbservice: %s", err)
} }
@ -69,9 +69,9 @@
return fmt.Errorf("error creating instance instance: %s", err) return fmt.Errorf("error creating instance instance: %s", err)
} }
federatingDB := federatingdb.New(dbService, c, log) federatingDB := federatingdb.New(dbService, c)
router, err := router.New(ctx, c, dbService, log) router, err := router.New(ctx, c, dbService)
if err != nil { if err != nil {
return fmt.Errorf("error creating router: %s", err) return fmt.Errorf("error creating router: %s", err)
} }
@ -83,48 +83,48 @@
} }
// build converters and util // build converters and util
typeConverter := typeutils.NewConverter(c, dbService, log) typeConverter := typeutils.NewConverter(c, dbService)
timelineManager := timelineprocessing.NewManager(dbService, typeConverter, c, log) timelineManager := timelineprocessing.NewManager(dbService, typeConverter, c)
// build backend handlers // build backend handlers
mediaHandler := media.New(c, dbService, storage, log) mediaHandler := media.New(c, dbService, storage)
oauthServer := oauth.New(ctx, dbService, log) oauthServer := oauth.New(ctx, dbService)
transportController := transport.NewController(c, dbService, &federation.Clock{}, http.DefaultClient, log) transportController := transport.NewController(c, dbService, &federation.Clock{}, http.DefaultClient)
federator := federation.NewFederator(dbService, federatingDB, transportController, c, log, typeConverter, mediaHandler) federator := federation.NewFederator(dbService, federatingDB, transportController, c, typeConverter, mediaHandler)
processor := processing.NewProcessor(c, typeConverter, federator, oauthServer, mediaHandler, storage, timelineManager, dbService, log) processor := processing.NewProcessor(c, typeConverter, federator, oauthServer, mediaHandler, storage, timelineManager, dbService)
if err := processor.Start(ctx); err != nil { if err := processor.Start(ctx); err != nil {
return fmt.Errorf("error starting processor: %s", err) return fmt.Errorf("error starting processor: %s", err)
} }
idp, err := oidc.NewIDP(ctx, c, log) idp, err := oidc.NewIDP(ctx, c)
if err != nil { if err != nil {
return fmt.Errorf("error creating oidc idp: %s", err) return fmt.Errorf("error creating oidc idp: %s", err)
} }
// build client api modules // build client api modules
authModule := auth.New(c, dbService, oauthServer, idp, log) authModule := auth.New(c, dbService, oauthServer, idp)
accountModule := account.New(c, processor, log) accountModule := account.New(c, processor)
instanceModule := instance.New(c, processor, log) instanceModule := instance.New(c, processor)
appsModule := app.New(c, processor, log) appsModule := app.New(c, processor)
followRequestsModule := followrequest.New(c, processor, log) followRequestsModule := followrequest.New(c, processor)
webfingerModule := webfinger.New(c, processor, log) webfingerModule := webfinger.New(c, processor)
nodeInfoModule := nodeinfo.New(c, processor, log) nodeInfoModule := nodeinfo.New(c, processor)
webBaseModule := web.New(c, processor, log) webBaseModule := web.New(c, processor)
usersModule := user.New(c, processor, log) usersModule := user.New(c, processor)
timelineModule := timeline.New(c, processor, log) timelineModule := timeline.New(c, processor)
notificationModule := notification.New(c, processor, log) notificationModule := notification.New(c, processor)
searchModule := search.New(c, processor, log) searchModule := search.New(c, processor)
filtersModule := filter.New(c, processor, log) filtersModule := filter.New(c, processor)
emojiModule := emoji.New(c, processor, log) emojiModule := emoji.New(c, processor)
listsModule := list.New(c, processor, log) listsModule := list.New(c, processor)
mm := mediaModule.New(c, processor, log) mm := mediaModule.New(c, processor)
fileServerModule := fileserver.New(c, processor, log) fileServerModule := fileserver.New(c, processor)
adminModule := admin.New(c, processor, log) adminModule := admin.New(c, processor)
statusModule := status.New(c, processor, log) statusModule := status.New(c, processor)
securityModule := security.New(c, dbService, log) securityModule := security.New(c, dbService)
streamingModule := streaming.New(c, processor, log) streamingModule := streaming.New(c, processor)
favouritesModule := favourites.New(c, processor, log) favouritesModule := favourites.New(c, processor)
blocksModule := blocks.New(c, processor, log) blocksModule := blocks.New(c, processor)
apis := []api.ClientModule{ apis := []api.ClientModule{
// modules with middleware go first // modules with middleware go first
@ -174,13 +174,13 @@
sigs := make(chan os.Signal, 1) sigs := make(chan os.Signal, 1)
signal.Notify(sigs, os.Interrupt, syscall.SIGTERM) signal.Notify(sigs, os.Interrupt, syscall.SIGTERM)
sig := <-sigs sig := <-sigs
log.Infof("received signal %s, shutting down", sig) logrus.Infof("received signal %s, shutting down", sig)
// close down all running services in order // close down all running services in order
if err := gts.Stop(ctx); err != nil { if err := gts.Stop(ctx); err != nil {
return fmt.Errorf("error closing gotosocial service: %s", err) return fmt.Errorf("error closing gotosocial service: %s", err)
} }
log.Info("done! exiting...") logrus.Info("done! exiting...")
return nil return nil
} }

View File

@ -43,7 +43,7 @@
) )
// Start creates and starts a gotosocial testrig server // Start creates and starts a gotosocial testrig server
var Start cliactions.GTSAction = func(ctx context.Context, _ *config.Config, log *logrus.Logger) error { var Start cliactions.GTSAction = func(ctx context.Context, _ *config.Config) error {
c := testrig.NewTestConfig() c := testrig.NewTestConfig()
dbService := testrig.NewTestDB() dbService := testrig.NewTestDB()
testrig.StandardDBSetup(dbService, nil) testrig.StandardDBSetup(dbService, nil)
@ -67,35 +67,35 @@
return fmt.Errorf("error starting processor: %s", err) return fmt.Errorf("error starting processor: %s", err)
} }
idp, err := oidc.NewIDP(ctx, c, log) idp, err := oidc.NewIDP(ctx, c)
if err != nil { if err != nil {
return fmt.Errorf("error creating oidc idp: %s", err) return fmt.Errorf("error creating oidc idp: %s", err)
} }
// build client api modules // build client api modules
authModule := auth.New(c, dbService, oauthServer, idp, log) authModule := auth.New(c, dbService, oauthServer, idp)
accountModule := account.New(c, processor, log) accountModule := account.New(c, processor)
instanceModule := instance.New(c, processor, log) instanceModule := instance.New(c, processor)
appsModule := app.New(c, processor, log) appsModule := app.New(c, processor)
followRequestsModule := followrequest.New(c, processor, log) followRequestsModule := followrequest.New(c, processor)
webfingerModule := webfinger.New(c, processor, log) webfingerModule := webfinger.New(c, processor)
nodeInfoModule := nodeinfo.New(c, processor, log) nodeInfoModule := nodeinfo.New(c, processor)
webBaseModule := web.New(c, processor, log) webBaseModule := web.New(c, processor)
usersModule := user.New(c, processor, log) usersModule := user.New(c, processor)
timelineModule := timeline.New(c, processor, log) timelineModule := timeline.New(c, processor)
notificationModule := notification.New(c, processor, log) notificationModule := notification.New(c, processor)
searchModule := search.New(c, processor, log) searchModule := search.New(c, processor)
filtersModule := filter.New(c, processor, log) filtersModule := filter.New(c, processor)
emojiModule := emoji.New(c, processor, log) emojiModule := emoji.New(c, processor)
listsModule := list.New(c, processor, log) listsModule := list.New(c, processor)
mm := mediaModule.New(c, processor, log) mm := mediaModule.New(c, processor)
fileServerModule := fileserver.New(c, processor, log) fileServerModule := fileserver.New(c, processor)
adminModule := admin.New(c, processor, log) adminModule := admin.New(c, processor)
statusModule := status.New(c, processor, log) statusModule := status.New(c, processor)
securityModule := security.New(c, dbService, log) securityModule := security.New(c, dbService)
streamingModule := streaming.New(c, processor, log) streamingModule := streaming.New(c, processor)
favouritesModule := favourites.New(c, processor, log) favouritesModule := favourites.New(c, processor)
blocksModule := blocks.New(c, processor, log) blocksModule := blocks.New(c, processor)
apis := []api.ClientModule{ apis := []api.ClientModule{
// modules with middleware go first // modules with middleware go first
@ -145,7 +145,7 @@
sigs := make(chan os.Signal, 1) sigs := make(chan os.Signal, 1)
signal.Notify(sigs, os.Interrupt, syscall.SIGTERM) signal.Notify(sigs, os.Interrupt, syscall.SIGTERM)
sig := <-sigs sig := <-sigs
log.Infof("received signal %s, shutting down", sig) logrus.Infof("received signal %s, shutting down", sig)
testrig.StandardDBTeardown(dbService) testrig.StandardDBTeardown(dbService)
testrig.StandardStorageTeardown(storageBackend) testrig.StandardStorageTeardown(storageBackend)
@ -155,6 +155,6 @@
return fmt.Errorf("error closing gotosocial service: %s", err) return fmt.Errorf("error closing gotosocial service: %s", err)
} }
log.Info("done! exiting...") logrus.Info("done! exiting...")
return nil return nil
} }

View File

@ -24,6 +24,7 @@
"crypto/rsa" "crypto/rsa"
"database/sql" "database/sql"
"fmt" "fmt"
"github.com/sirupsen/logrus"
"net" "net"
"net/mail" "net/mail"
"strings" "strings"
@ -86,7 +87,7 @@ func (a *adminDB) IsEmailAvailable(ctx context.Context, email string) (bool, db.
func (a *adminDB) NewSignup(ctx context.Context, username string, reason string, requireApproval bool, email string, password string, signUpIP net.IP, locale string, appID string, emailVerified bool, admin bool) (*gtsmodel.User, db.Error) { func (a *adminDB) NewSignup(ctx context.Context, username string, reason string, requireApproval bool, email string, password string, signUpIP net.IP, locale string, appID string, emailVerified bool, admin bool) (*gtsmodel.User, db.Error) {
key, err := rsa.GenerateKey(rand.Reader, 2048) key, err := rsa.GenerateKey(rand.Reader, 2048)
if err != nil { if err != nil {
a.conn.log.Errorf("error creating new rsa key: %s", err) logrus.Errorf("error creating new rsa key: %s", err)
return nil, err return nil, err
} }
@ -183,7 +184,7 @@ func (a *adminDB) CreateInstanceAccount(ctx context.Context) db.Error {
WhereGroup(" AND ", whereEmptyOrNull("domain")) WhereGroup(" AND ", whereEmptyOrNull("domain"))
count, err := existsQ.Count(ctx) count, err := existsQ.Count(ctx)
if err != nil && count == 1 { if err != nil && count == 1 {
a.conn.log.Infof("instance account %s already exists", username) logrus.Infof("instance account %s already exists", username)
return nil return nil
} else if err != sql.ErrNoRows { } else if err != sql.ErrNoRows {
return a.conn.ProcessError(err) return a.conn.ProcessError(err)
@ -191,7 +192,7 @@ func (a *adminDB) CreateInstanceAccount(ctx context.Context) db.Error {
key, err := rsa.GenerateKey(rand.Reader, 2048) key, err := rsa.GenerateKey(rand.Reader, 2048)
if err != nil { if err != nil {
a.conn.log.Errorf("error creating new rsa key: %s", err) logrus.Errorf("error creating new rsa key: %s", err)
return err return err
} }
@ -226,7 +227,7 @@ func (a *adminDB) CreateInstanceAccount(ctx context.Context) db.Error {
return a.conn.ProcessError(err) return a.conn.ProcessError(err)
} }
a.conn.log.Infof("instance account %s CREATED with id %s", username, acct.ID) logrus.Infof("instance account %s CREATED with id %s", username, acct.ID)
return nil return nil
} }
@ -244,7 +245,7 @@ func (a *adminDB) CreateInstanceInstance(ctx context.Context) db.Error {
return err return err
} }
if exists { if exists {
a.conn.log.Infof("instance entry already exists") logrus.Infof("instance entry already exists")
return nil return nil
} }
@ -269,6 +270,6 @@ func (a *adminDB) CreateInstanceInstance(ctx context.Context) db.Error {
return a.conn.ProcessError(err) return a.conn.ProcessError(err)
} }
a.conn.log.Infof("created instance instance %s with id %s", domain, i.ID) logrus.Infof("created instance instance %s with id %s", domain, i.ID)
return nil return nil
} }

Some files were not shown because too many files have changed in this diff Show More