mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
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:
committed by
GitHub
parent
367bdca250
commit
083099a957
@@ -23,7 +23,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -75,15 +74,13 @@ const (
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -8,7 +8,6 @@ import (
|
||||
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api/client/account"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
@@ -26,7 +25,6 @@ type AccountStandardTestSuite struct {
|
||||
suite.Suite
|
||||
config *config.Config
|
||||
db db.DB
|
||||
log *logrus.Logger
|
||||
tc typeutils.TypeConverter
|
||||
storage *kv.KVStore
|
||||
federator federation.Federator
|
||||
@@ -59,10 +57,10 @@ func (suite *AccountStandardTestSuite) SetupTest() {
|
||||
suite.config = testrig.NewTestConfig()
|
||||
suite.db = testrig.NewTestDB()
|
||||
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.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.StandardStorageSetup(suite.storage, "../../../../testrig/media")
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ package account
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
@@ -67,7 +68,7 @@ import (
|
||||
// '500':
|
||||
// description: internal error
|
||||
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)
|
||||
if err != nil {
|
||||
l.Debugf("couldn't auth: %s", err)
|
||||
|
@@ -20,6 +20,7 @@ package account
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -100,7 +101,7 @@ import (
|
||||
// '400':
|
||||
// description: bad request
|
||||
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)
|
||||
if err != nil {
|
||||
l.Debugf("couldn't auth: %s", err)
|
||||
|
@@ -19,6 +19,7 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -51,7 +52,7 @@ import (
|
||||
// '404':
|
||||
// description: not found
|
||||
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)
|
||||
if err != nil {
|
||||
l.Debugf("couldn't auth: %s", err)
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -47,7 +48,7 @@ import (
|
||||
// '404':
|
||||
// description: not found
|
||||
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)
|
||||
if err != nil {
|
||||
|
@@ -19,6 +19,7 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -96,7 +97,7 @@ import (
|
||||
// '404':
|
||||
// description: not found
|
||||
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)
|
||||
if err != nil {
|
||||
|
@@ -19,6 +19,7 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -60,7 +61,7 @@ import (
|
||||
// '404':
|
||||
// description: not found
|
||||
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)
|
||||
if err != nil {
|
||||
l.Debug(err)
|
||||
|
@@ -21,7 +21,6 @@ package admin
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -50,15 +49,13 @@ const (
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -90,7 +90,7 @@ import (
|
||||
// '400':
|
||||
// description: bad request
|
||||
func (m *Module) DomainBlocksPOSTHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "DomainBlocksPOSTHandler",
|
||||
"request_uri": c.Request.RequestURI,
|
||||
"user_agent": c.Request.UserAgent(),
|
||||
|
@@ -42,7 +42,7 @@ import (
|
||||
// '404':
|
||||
// description: not found
|
||||
func (m *Module) DomainBlockDELETEHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "DomainBlockDELETEHandler",
|
||||
"request_uri": c.Request.RequestURI,
|
||||
"user_agent": c.Request.UserAgent(),
|
||||
|
@@ -43,7 +43,7 @@ import (
|
||||
// '404':
|
||||
// description: not found
|
||||
func (m *Module) DomainBlockGETHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "DomainBlockGETHandler",
|
||||
"request_uri": c.Request.RequestURI,
|
||||
"user_agent": c.Request.UserAgent(),
|
||||
|
@@ -49,7 +49,7 @@ import (
|
||||
// '404':
|
||||
// description: not found
|
||||
func (m *Module) DomainBlocksGETHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "DomainBlocksGETHandler",
|
||||
"request_uri": c.Request.RequestURI,
|
||||
"user_agent": c.Request.UserAgent(),
|
||||
|
@@ -74,7 +74,7 @@ import (
|
||||
// '400':
|
||||
// description: bad request
|
||||
func (m *Module) emojiCreatePOSTHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "emojiCreatePOSTHandler",
|
||||
"request_uri": c.Request.RequestURI,
|
||||
"user_agent": c.Request.UserAgent(),
|
||||
|
@@ -21,7 +21,6 @@ package app
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -35,15 +34,13 @@ const BasePath = "/api/v1/apps"
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,6 +20,7 @@ package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -63,7 +64,7 @@ import (
|
||||
// '500':
|
||||
// description: internal error
|
||||
func (m *Module) AppsPOSTHandler(c *gin.Context) {
|
||||
l := m.log.WithField("func", "AppsPOSTHandler")
|
||||
l := logrus.WithField("func", "AppsPOSTHandler")
|
||||
l.Trace("entering AppsPOSTHandler")
|
||||
|
||||
authed, err := oauth.Authed(c, false, false, false, false)
|
||||
|
@@ -21,7 +21,6 @@ package auth
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
@@ -58,17 +57,15 @@ type Module struct {
|
||||
db db.DB
|
||||
server oauth.Server
|
||||
idp oidc.IDP
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
db: db,
|
||||
server: server,
|
||||
idp: idp,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -103,7 +103,7 @@ func (suite *AuthTestSuite) SetupTest() {
|
||||
|
||||
log := logrus.New()
|
||||
log.SetLevel(logrus.TraceLevel)
|
||||
db, err := bundb.NewBunDBService(context.Background(), suite.config, log)
|
||||
db, err := bundb.NewBunDBService(context.Background(), suite.config)
|
||||
if err != nil {
|
||||
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 {
|
||||
logrus.Panicf("could not insert test account into db: %s", err)
|
||||
|
@@ -21,6 +21,7 @@ package auth
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
@@ -37,7 +38,7 @@ import (
|
||||
// The idea here is to present an oauth authorize page to the user, with a button
|
||||
// that they have to click to accept.
|
||||
func (m *Module) AuthorizeGETHandler(c *gin.Context) {
|
||||
l := m.log.WithField("func", "AuthorizeGETHandler")
|
||||
l := logrus.WithField("func", "AuthorizeGETHandler")
|
||||
s := sessions.Default(c)
|
||||
|
||||
// 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,
|
||||
// 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) {
|
||||
l := m.log.WithField("func", "AuthorizePOSTHandler")
|
||||
l := logrus.WithField("func", "AuthorizePOSTHandler")
|
||||
s := sessions.Default(c)
|
||||
|
||||
// We need to retrieve the original form submitted to the authorizeGEThandler, and
|
||||
|
@@ -20,6 +20,7 @@ package auth
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/oauth"
|
||||
@@ -31,7 +32,7 @@ import (
|
||||
// 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).
|
||||
func (m *Module) OauthTokenMiddleware(c *gin.Context) {
|
||||
l := m.log.WithField("func", "OauthTokenMiddleware")
|
||||
l := logrus.WithField("func", "OauthTokenMiddleware")
|
||||
l.Trace("entering OauthTokenMiddleware")
|
||||
|
||||
ti, err := m.server.ValidationBearerToken(c.Copy().Request)
|
||||
|
@@ -21,6 +21,7 @@ package auth
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
|
||||
"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 form will then POST to the sign in page, which will be handled by SignInPOSTHandler
|
||||
func (m *Module) SignInGETHandler(c *gin.Context) {
|
||||
l := m.log.WithField("func", "SignInGETHandler")
|
||||
l := logrus.WithField("func", "SignInGETHandler")
|
||||
l.Trace("entering sign in handler")
|
||||
if m.idp != nil {
|
||||
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 handler will then redirect to the auth handler served at /auth
|
||||
func (m *Module) SignInPOSTHandler(c *gin.Context) {
|
||||
l := m.log.WithField("func", "SignInPOSTHandler")
|
||||
l := logrus.WithField("func", "SignInPOSTHandler")
|
||||
s := sessions.Default(c)
|
||||
form := &login{}
|
||||
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,
|
||||
// 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) {
|
||||
l := m.log.WithField("func", "ValidatePassword")
|
||||
l := logrus.WithField("func", "ValidatePassword")
|
||||
|
||||
// make sure an email/password was provided and bail if not
|
||||
if email == "" || password == "" {
|
||||
|
@@ -19,6 +19,7 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
@@ -37,7 +38,7 @@ type tokenBody struct {
|
||||
// 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.
|
||||
func (m *Module) TokenPOSTHandler(c *gin.Context) {
|
||||
l := m.log.WithField("func", "TokenPOSTHandler")
|
||||
l := logrus.WithField("func", "TokenPOSTHandler")
|
||||
l.Trace("entered TokenPOSTHandler")
|
||||
|
||||
form := &tokenBody{}
|
||||
|
@@ -21,7 +21,6 @@ package blocks
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -44,15 +43,13 @@ const (
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -19,6 +19,7 @@
|
||||
package blocks
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -84,7 +85,7 @@ import (
|
||||
// '404':
|
||||
// description: not found
|
||||
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)
|
||||
if err != nil {
|
||||
|
@@ -21,7 +21,6 @@ package emoji
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -37,15 +36,13 @@ const (
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,6 @@ package favourites
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -48,15 +47,13 @@ const (
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package favourites
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -10,7 +11,7 @@ import (
|
||||
|
||||
// FavouritesGETHandler handles GETting favourites.
|
||||
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)
|
||||
if err != nil {
|
||||
|
@@ -22,7 +22,6 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -45,16 +44,14 @@ const (
|
||||
type FileServer struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
storageBase string
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
storageBase: config.StorageConfig.ServeBasePath,
|
||||
}
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ import (
|
||||
// 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.
|
||||
func (m *FileServer) ServeFile(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "ServeFile",
|
||||
"request_uri": c.Request.RequestURI,
|
||||
"user_agent": c.Request.UserAgent(),
|
||||
|
@@ -48,7 +48,6 @@ type ServeFileTestSuite struct {
|
||||
suite.Suite
|
||||
config *config.Config
|
||||
db db.DB
|
||||
log *logrus.Logger
|
||||
storage *kv.KVStore
|
||||
federator federation.Federator
|
||||
tc typeutils.TypeConverter
|
||||
@@ -76,7 +75,7 @@ func (suite *ServeFileTestSuite) SetupSuite() {
|
||||
// setup standard items
|
||||
suite.config = testrig.NewTestConfig()
|
||||
suite.db = testrig.NewTestDB()
|
||||
suite.log = testrig.NewTestLog()
|
||||
testrig.InitTestLog()
|
||||
suite.storage = testrig.NewTestStorage()
|
||||
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)
|
||||
@@ -85,7 +84,7 @@ func (suite *ServeFileTestSuite) SetupSuite() {
|
||||
suite.oauthServer = testrig.NewTestOauthServer(suite.db)
|
||||
|
||||
// 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() {
|
||||
|
@@ -21,7 +21,6 @@ package filter
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -37,15 +36,13 @@ const (
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -19,6 +19,7 @@
|
||||
package followrequest
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -28,7 +29,7 @@ import (
|
||||
// FollowRequestAcceptPOSTHandler deals with follow request accepting. It should be served at
|
||||
// /api/v1/follow_requests/:id/authorize
|
||||
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)
|
||||
if err != nil {
|
||||
l.Debugf("couldn't auth: %s", err)
|
||||
|
@@ -21,7 +21,6 @@ package followrequest
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -47,15 +46,13 @@ const (
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -19,6 +19,7 @@
|
||||
package followrequest
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -27,7 +28,7 @@ import (
|
||||
|
||||
// FollowRequestGETHandler allows clients to get a list of their incoming follow requests.
|
||||
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)
|
||||
if err != nil {
|
||||
l.Debugf("couldn't auth: %s", err)
|
||||
|
@@ -3,7 +3,6 @@ package instance
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -19,15 +18,13 @@ const (
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package instance
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -29,7 +30,7 @@ import (
|
||||
// '500':
|
||||
// description: internal error
|
||||
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)
|
||||
if err != nil {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package instance
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -84,7 +85,7 @@ import (
|
||||
// '400':
|
||||
// description: bad request
|
||||
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)
|
||||
if err != nil {
|
||||
l.Debugf("couldn't auth: %s", err)
|
||||
|
@@ -21,7 +21,6 @@ package list
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -37,15 +36,13 @@ const (
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,6 @@ package media
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -41,15 +40,13 @@ const BasePathWithID = BasePath + "/:" + IDKey
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -21,6 +21,7 @@ package media
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -82,7 +83,7 @@ import (
|
||||
// '422':
|
||||
// description: unprocessable
|
||||
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*
|
||||
if err != nil {
|
||||
l.Debugf("couldn't auth: %s", err)
|
||||
|
@@ -51,7 +51,6 @@ type MediaCreateTestSuite struct {
|
||||
suite.Suite
|
||||
config *config.Config
|
||||
db db.DB
|
||||
log *logrus.Logger
|
||||
storage *kv.KVStore
|
||||
federator federation.Federator
|
||||
tc typeutils.TypeConverter
|
||||
@@ -79,7 +78,7 @@ func (suite *MediaCreateTestSuite) SetupSuite() {
|
||||
// setup standard items
|
||||
suite.config = testrig.NewTestConfig()
|
||||
suite.db = testrig.NewTestDB()
|
||||
suite.log = testrig.NewTestLog()
|
||||
testrig.InitTestLog()
|
||||
suite.storage = testrig.NewTestStorage()
|
||||
suite.tc = testrig.NewTestTypeConverter(suite.db)
|
||||
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)
|
||||
|
||||
// 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() {
|
||||
|
@@ -19,6 +19,7 @@
|
||||
package media
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -61,7 +62,7 @@ import (
|
||||
// '422':
|
||||
// description: unprocessable
|
||||
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)
|
||||
if err != nil {
|
||||
l.Debugf("couldn't auth: %s", err)
|
||||
|
@@ -21,6 +21,7 @@ package media
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -91,7 +92,7 @@ import (
|
||||
// '422':
|
||||
// description: unprocessable
|
||||
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)
|
||||
if err != nil {
|
||||
l.Debugf("couldn't auth: %s", err)
|
||||
|
@@ -21,7 +21,6 @@ package notification
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -49,15 +48,13 @@ const (
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -29,7 +29,7 @@ import (
|
||||
|
||||
// NotificationsGETHandler serves a list of notifications to the caller, with the desired query parameters
|
||||
func (m *Module) NotificationsGETHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "NotificationsGETHandler",
|
||||
"request_uri": c.Request.RequestURI,
|
||||
"user_agent": c.Request.UserAgent(),
|
||||
|
@@ -21,7 +21,6 @@ package search
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -68,15 +67,13 @@ const (
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -56,7 +56,7 @@ import (
|
||||
// '400':
|
||||
// description: bad request
|
||||
func (m *Module) SearchGETHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "SearchGETHandler",
|
||||
"request_uri": c.Request.RequestURI,
|
||||
"user_agent": c.Request.UserAgent(),
|
||||
|
@@ -19,11 +19,11 @@
|
||||
package status
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -76,15 +76,13 @@ const (
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
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
|
||||
func (m *Module) muxHandler(c *gin.Context) {
|
||||
m.log.Debug("entering mux handler")
|
||||
logrus.Debug("entering mux handler")
|
||||
ru := c.Request.RequestURI
|
||||
|
||||
switch c.Request.Method {
|
||||
|
@@ -20,7 +20,6 @@ package status_test
|
||||
|
||||
import (
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api/client/status"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
@@ -37,7 +36,6 @@ type StatusStandardTestSuite struct {
|
||||
suite.Suite
|
||||
config *config.Config
|
||||
db db.DB
|
||||
log *logrus.Logger
|
||||
tc typeutils.TypeConverter
|
||||
federator federation.Federator
|
||||
processor processing.Processor
|
||||
|
@@ -66,7 +66,7 @@ import (
|
||||
// '404':
|
||||
// description: not found
|
||||
func (m *Module) StatusBoostPOSTHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "StatusBoostPOSTHandler",
|
||||
"request_uri": c.Request.RequestURI,
|
||||
"user_agent": c.Request.UserAgent(),
|
||||
|
@@ -51,10 +51,10 @@ func (suite *StatusBoostTestSuite) SetupTest() {
|
||||
suite.config = testrig.NewTestConfig()
|
||||
suite.db = testrig.NewTestDB()
|
||||
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.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.StandardStorageSetup(suite.storage, "../../../../testrig/media")
|
||||
}
|
||||
|
@@ -63,7 +63,7 @@ import (
|
||||
// '404':
|
||||
// description: not found
|
||||
func (m *Module) StatusBoostedByGETHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "StatusBoostedByGETHandler",
|
||||
"request_uri": c.Request.RequestURI,
|
||||
"user_agent": c.Request.UserAgent(),
|
||||
|
@@ -65,7 +65,7 @@ import (
|
||||
// '404':
|
||||
// description: not found
|
||||
func (m *Module) StatusContextGETHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "StatusContextGETHandler",
|
||||
"request_uri": c.Request.RequestURI,
|
||||
"user_agent": c.Request.UserAgent(),
|
||||
|
@@ -21,6 +21,7 @@ package status
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -67,7 +68,7 @@ import (
|
||||
// '500':
|
||||
// description: internal error
|
||||
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*
|
||||
if err != nil {
|
||||
l.Debugf("couldn't auth: %s", err)
|
||||
|
@@ -57,11 +57,11 @@ func (suite *StatusCreateTestSuite) SetupTest() {
|
||||
suite.config = testrig.NewTestConfig()
|
||||
suite.db = testrig.NewTestDB()
|
||||
suite.storage = testrig.NewTestStorage()
|
||||
suite.log = testrig.NewTestLog()
|
||||
testrig.InitTestLog()
|
||||
suite.tc = testrig.NewTestTypeConverter(suite.db)
|
||||
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.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.StandardStorageSetup(suite.storage, "../../../../testrig/media")
|
||||
}
|
||||
|
@@ -65,7 +65,7 @@ import (
|
||||
// '404':
|
||||
// description: not found
|
||||
func (m *Module) StatusDELETEHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "StatusDELETEHandler",
|
||||
"request_uri": c.Request.RequestURI,
|
||||
"user_agent": c.Request.UserAgent(),
|
||||
|
@@ -62,7 +62,7 @@ import (
|
||||
// '404':
|
||||
// description: not found
|
||||
func (m *Module) StatusFavePOSTHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "StatusFavePOSTHandler",
|
||||
"request_uri": c.Request.RequestURI,
|
||||
"user_agent": c.Request.UserAgent(),
|
||||
|
@@ -54,10 +54,10 @@ func (suite *StatusFaveTestSuite) SetupTest() {
|
||||
suite.config = testrig.NewTestConfig()
|
||||
suite.db = testrig.NewTestDB()
|
||||
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.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.StandardStorageSetup(suite.storage, "../../../../testrig/media")
|
||||
}
|
||||
|
@@ -63,7 +63,7 @@ import (
|
||||
// '404':
|
||||
// description: not found
|
||||
func (m *Module) StatusFavedByGETHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "statusGETHandler",
|
||||
"request_uri": c.Request.RequestURI,
|
||||
"user_agent": c.Request.UserAgent(),
|
||||
|
@@ -54,10 +54,10 @@ func (suite *StatusFavedByTestSuite) SetupTest() {
|
||||
suite.config = testrig.NewTestConfig()
|
||||
suite.db = testrig.NewTestDB()
|
||||
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.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.StandardStorageSetup(suite.storage, "../../../../testrig/media")
|
||||
}
|
||||
|
@@ -62,7 +62,7 @@ import (
|
||||
// '500':
|
||||
// description: internal error
|
||||
func (m *Module) StatusGETHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "statusGETHandler",
|
||||
"request_uri": c.Request.RequestURI,
|
||||
"user_agent": c.Request.UserAgent(),
|
||||
|
@@ -44,10 +44,10 @@ func (suite *StatusGetTestSuite) SetupTest() {
|
||||
suite.config = testrig.NewTestConfig()
|
||||
suite.db = testrig.NewTestDB()
|
||||
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.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.StandardStorageSetup(suite.storage, "../../../../testrig/media")
|
||||
}
|
||||
|
@@ -63,7 +63,7 @@ import (
|
||||
// '404':
|
||||
// description: not found
|
||||
func (m *Module) StatusUnboostPOSTHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "StatusUnboostPOSTHandler",
|
||||
"request_uri": c.Request.RequestURI,
|
||||
"user_agent": c.Request.UserAgent(),
|
||||
|
@@ -62,7 +62,7 @@ import (
|
||||
// '404':
|
||||
// description: not found
|
||||
func (m *Module) StatusUnfavePOSTHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "StatusUnfavePOSTHandler",
|
||||
"request_uri": c.Request.RequestURI,
|
||||
"user_agent": c.Request.UserAgent(),
|
||||
|
@@ -54,10 +54,10 @@ func (suite *StatusUnfaveTestSuite) SetupTest() {
|
||||
suite.config = testrig.NewTestConfig()
|
||||
suite.db = testrig.NewTestDB()
|
||||
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.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.StandardStorageSetup(suite.storage, "../../../../testrig/media")
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package streaming
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@@ -107,7 +108,7 @@ import (
|
||||
// '400':
|
||||
// description: bad request
|
||||
func (m *Module) StreamGETHandler(c *gin.Context) {
|
||||
l := m.log.WithField("func", "StreamGETHandler")
|
||||
l := logrus.WithField("func", "StreamGETHandler")
|
||||
|
||||
streamType := c.Query(StreamQueryKey)
|
||||
if streamType == "" {
|
||||
|
@@ -21,7 +21,6 @@ package streaming
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -43,15 +42,13 @@ const (
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -19,6 +19,7 @@
|
||||
package timeline
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -102,7 +103,7 @@ import (
|
||||
// '400':
|
||||
// description: bad request
|
||||
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)
|
||||
if err != nil {
|
||||
|
@@ -19,6 +19,7 @@
|
||||
package timeline
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -102,7 +103,7 @@ import (
|
||||
// '400':
|
||||
// description: bad request
|
||||
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)
|
||||
if err != nil {
|
||||
|
@@ -21,7 +21,6 @@ package timeline
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -51,15 +50,13 @@ const (
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,6 @@ package nodeinfo
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -39,15 +38,13 @@ const (
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,7 @@ import (
|
||||
// NodeInfoGETHandler returns a compliant nodeinfo response to node info queries.
|
||||
// See: https://nodeinfo.diaspora.software/
|
||||
func (m *Module) NodeInfoGETHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "NodeInfoGETHandler",
|
||||
"user-agent": c.Request.UserAgent(),
|
||||
})
|
||||
|
@@ -28,7 +28,7 @@ import (
|
||||
// NodeInfoWellKnownGETHandler returns a well known response to a query to /.well-known/nodeinfo,
|
||||
// directing (but not redirecting...) callers to the NodeInfoGETHandler.
|
||||
func (m *Module) NodeInfoWellKnownGETHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "NodeInfoWellKnownGETHandler",
|
||||
"user-agent": c.Request.UserAgent(),
|
||||
})
|
||||
|
@@ -29,7 +29,7 @@ import (
|
||||
|
||||
// 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) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "FollowersGETHandler",
|
||||
"url": c.Request.RequestURI,
|
||||
})
|
||||
|
@@ -29,7 +29,7 @@ import (
|
||||
|
||||
// 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) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "FollowingGETHandler",
|
||||
"url": c.Request.RequestURI,
|
||||
})
|
||||
|
@@ -29,7 +29,7 @@ import (
|
||||
// InboxPOSTHandler deals with incoming POST requests to an actor's inbox.
|
||||
// Eg., POST to https://example.org/users/whatever/inbox.
|
||||
func (m *Module) InboxPOSTHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "InboxPOSTHandler",
|
||||
"url": c.Request.RequestURI,
|
||||
})
|
||||
|
@@ -86,7 +86,7 @@ func (suite *InboxPostTestSuite) TestPostBlock() {
|
||||
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
|
||||
federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
|
||||
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
|
||||
recorder := httptest.NewRecorder()
|
||||
@@ -185,7 +185,7 @@ func (suite *InboxPostTestSuite) TestPostUnblock() {
|
||||
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
|
||||
federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
|
||||
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
|
||||
recorder := httptest.NewRecorder()
|
||||
@@ -274,7 +274,7 @@ func (suite *InboxPostTestSuite) TestPostUpdate() {
|
||||
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
|
||||
federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
|
||||
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
|
||||
recorder := httptest.NewRecorder()
|
||||
@@ -394,7 +394,7 @@ func (suite *InboxPostTestSuite) TestPostDelete() {
|
||||
processor := testrig.NewTestProcessor(suite.db, suite.storage, federator)
|
||||
err = processor.Start(context.Background())
|
||||
suite.NoError(err)
|
||||
userModule := user.New(suite.config, processor, suite.log).(*user.Module)
|
||||
userModule := user.New(suite.config, processor).(*user.Module)
|
||||
|
||||
// setup request
|
||||
recorder := httptest.NewRecorder()
|
||||
|
@@ -33,7 +33,7 @@ import (
|
||||
// in the form of a vocab.ActivityStreamsPerson. The account will only contain the id,
|
||||
// public key, username, and type of the account.
|
||||
func (m *Module) PublicKeyGETHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "PublicKeyGETHandler",
|
||||
"url": c.Request.RequestURI,
|
||||
})
|
||||
|
@@ -85,7 +85,7 @@ import (
|
||||
// '404':
|
||||
// description: not found
|
||||
func (m *Module) StatusRepliesGETHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "StatusRepliesGETHandler",
|
||||
"url": c.Request.RequestURI,
|
||||
})
|
||||
|
@@ -50,7 +50,7 @@ func (suite *RepliesGetTestSuite) TestGetReplies() {
|
||||
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
|
||||
federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
|
||||
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
|
||||
recorder := httptest.NewRecorder()
|
||||
@@ -109,7 +109,7 @@ func (suite *RepliesGetTestSuite) TestGetRepliesNext() {
|
||||
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
|
||||
federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
|
||||
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
|
||||
recorder := httptest.NewRecorder()
|
||||
@@ -171,7 +171,7 @@ func (suite *RepliesGetTestSuite) TestGetRepliesLast() {
|
||||
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
|
||||
federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
|
||||
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
|
||||
recorder := httptest.NewRecorder()
|
||||
|
@@ -29,7 +29,7 @@ import (
|
||||
|
||||
// StatusGETHandler serves the target status as an activitystreams NOTE so that other AP servers can parse it.
|
||||
func (m *Module) StatusGETHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "StatusGETHandler",
|
||||
"url": c.Request.RequestURI,
|
||||
})
|
||||
|
@@ -21,7 +21,6 @@ package user
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -65,15 +64,13 @@ const (
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,7 +20,6 @@ package user_test
|
||||
|
||||
import (
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api/s2s/user"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api/security"
|
||||
@@ -38,7 +37,6 @@ type UserStandardTestSuite struct {
|
||||
suite.Suite
|
||||
config *config.Config
|
||||
db db.DB
|
||||
log *logrus.Logger
|
||||
tc typeutils.TypeConverter
|
||||
federator federation.Federator
|
||||
processor processing.Processor
|
||||
@@ -75,11 +73,11 @@ func (suite *UserStandardTestSuite) SetupTest() {
|
||||
suite.db = testrig.NewTestDB()
|
||||
suite.tc = testrig.NewTestTypeConverter(suite.db)
|
||||
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.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator)
|
||||
suite.userModule = user.New(suite.config, suite.processor, suite.log).(*user.Module)
|
||||
suite.securityModule = security.New(suite.config, suite.db, suite.log).(*security.Module)
|
||||
suite.userModule = user.New(suite.config, suite.processor).(*user.Module)
|
||||
suite.securityModule = security.New(suite.config, suite.db).(*security.Module)
|
||||
testrig.StandardDBSetup(suite.db, suite.testAccounts)
|
||||
testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media")
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ import (
|
||||
// And of course, the request should be refused if the account or server making the
|
||||
// request is blocked.
|
||||
func (m *Module) UsersGETHandler(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "UsersGETHandler",
|
||||
"url": c.Request.RequestURI,
|
||||
})
|
||||
|
@@ -48,7 +48,7 @@ func (suite *UserGetTestSuite) TestGetUser() {
|
||||
tc := testrig.NewTestTransportController(testrig.NewMockHTTPClient(nil), suite.db)
|
||||
federator := testrig.NewTestFederator(suite.db, tc, suite.storage)
|
||||
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
|
||||
recorder := httptest.NewRecorder()
|
||||
|
@@ -21,7 +21,6 @@ package webfinger
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/processing"
|
||||
@@ -37,15 +36,13 @@ const (
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
processor processing.Processor
|
||||
log *logrus.Logger
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
processor: processor,
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,6 @@ import (
|
||||
"time"
|
||||
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api/s2s/webfinger"
|
||||
@@ -43,7 +42,6 @@ type WebfingerStandardTestSuite struct {
|
||||
suite.Suite
|
||||
config *config.Config
|
||||
db db.DB
|
||||
log *logrus.Logger
|
||||
tc typeutils.TypeConverter
|
||||
federator federation.Federator
|
||||
processor processing.Processor
|
||||
@@ -78,11 +76,11 @@ func (suite *WebfingerStandardTestSuite) SetupTest() {
|
||||
suite.db = testrig.NewTestDB()
|
||||
suite.tc = testrig.NewTestTypeConverter(suite.db)
|
||||
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.processor = testrig.NewTestProcessor(suite.db, suite.storage, suite.federator)
|
||||
suite.webfingerModule = webfinger.New(suite.config, suite.processor, suite.log).(*webfinger.Module)
|
||||
suite.securityModule = security.New(suite.config, suite.db, suite.log).(*security.Module)
|
||||
suite.webfingerModule = webfinger.New(suite.config, suite.processor).(*webfinger.Module)
|
||||
suite.securityModule = security.New(suite.config, suite.db).(*security.Module)
|
||||
testrig.StandardDBSetup(suite.db, suite.testAccounts)
|
||||
testrig.StandardStorageSetup(suite.storage, "../../../../testrig/media")
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ import (
|
||||
|
||||
// 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) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "WebfingerGETRequest",
|
||||
"user-agent": c.Request.UserAgent(),
|
||||
})
|
||||
|
@@ -65,8 +65,8 @@ func (suite *WebfingerGetTestSuite) TestFingerUser() {
|
||||
func (suite *WebfingerGetTestSuite) TestFingerUserWithDifferentAccountDomainByHost() {
|
||||
suite.config.Host = "gts.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.webfingerModule = webfinger.New(suite.config, suite.processor, suite.log).(*webfinger.Module)
|
||||
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).(*webfinger.Module)
|
||||
|
||||
targetAccount := accountDomainAccount()
|
||||
if err := suite.db.Put(context.Background(), targetAccount); err != nil {
|
||||
@@ -97,8 +97,8 @@ func (suite *WebfingerGetTestSuite) TestFingerUserWithDifferentAccountDomainByHo
|
||||
func (suite *WebfingerGetTestSuite) TestFingerUserWithDifferentAccountDomainByAccountDomain() {
|
||||
suite.config.Host = "gts.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.webfingerModule = webfinger.New(suite.config, suite.processor, suite.log).(*webfinger.Module)
|
||||
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).(*webfinger.Module)
|
||||
|
||||
targetAccount := accountDomainAccount()
|
||||
if err := suite.db.Put(context.Background(), targetAccount); err != nil {
|
||||
|
@@ -21,7 +21,6 @@ package security
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
@@ -33,15 +32,13 @@ const robotsPath = "/robots.txt"
|
||||
// Module implements the ClientAPIModule interface for security middleware
|
||||
type Module struct {
|
||||
config *config.Config
|
||||
log *logrus.Logger
|
||||
db db.DB
|
||||
}
|
||||
|
||||
// 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{
|
||||
config: config,
|
||||
log: log,
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package security
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
@@ -13,7 +14,7 @@ import (
|
||||
// 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.
|
||||
func (m *Module) SignatureCheck(c *gin.Context) {
|
||||
l := m.log.WithField("func", "DomainBlockChecker")
|
||||
l := logrus.WithField("func", "DomainBlockChecker")
|
||||
|
||||
// create the verifier from the request
|
||||
// if the request is signed, it will have a signature header
|
||||
|
@@ -27,7 +27,7 @@ import (
|
||||
|
||||
// UserAgentBlock blocks requests with undesired, empty, or invalid user-agent strings.
|
||||
func (m *Module) UserAgentBlock(c *gin.Context) {
|
||||
l := m.log.WithFields(logrus.Fields{
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
"func": "UserAgentBlock",
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user