Move a lot of stuff + tidy stuff (#37)

Lots of renaming and moving stuff, some bug fixes, more lenient parsing of notifications and home timeline.
This commit is contained in:
Tobi Smethurst
2021-05-30 13:12:00 +02:00
committed by GitHub
parent c4d791be75
commit 3d77f81c7f
69 changed files with 342 additions and 719 deletions

View File

@ -26,7 +26,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/router"
)
@ -61,7 +61,7 @@ const (
GetFollowingPath = BasePathWithID + "/following"
// GetRelationshipsPath is for showing an account's relationship with other accounts
GetRelationshipsPath = BasePath + "/relationships"
// FollowPath is for POSTing new follows to, and updating existing follows
// PostFollowPath is for POSTing new follows to, and updating existing follows
PostFollowPath = BasePathWithID + "/follow"
// PostUnfollowPath is for POSTing an unfollow
PostUnfollowPath = BasePathWithID + "/unfollow"
@ -70,12 +70,12 @@ const (
// Module implements the ClientAPIModule interface for account-related actions
type Module struct {
config *config.Config
processor message.Processor
processor processing.Processor
log *logrus.Logger
}
// New returns a new account module
func New(config *config.Config, processor message.Processor, log *logrus.Logger) api.ClientModule {
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule {
return &Module{
config: config,
processor: processor,

View File

@ -4,13 +4,13 @@ import (
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/api/client/account"
"github.com/superseriousbusiness/gotosocial/internal/blob"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/federation"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
)
@ -22,9 +22,9 @@ type AccountStandardTestSuite struct {
db db.DB
log *logrus.Logger
tc typeutils.TypeConverter
storage storage.Storage
storage blob.Storage
federator federation.Federator
processor message.Processor
processor processing.Processor
// standard suite models
testTokens map[string]*oauth.Token

View File

@ -25,7 +25,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
// AccountFollowersGETHandler serves the followers of the requested account, if they're visible to the requester.
// AccountFollowingGETHandler serves the following of the requested account, if they're visible to the requester.
func (m *Module) AccountFollowingGETHandler(c *gin.Context) {
authed, err := oauth.Authed(c, true, true, true, true)
if err != nil {

View File

@ -24,7 +24,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/router"
)
@ -38,12 +38,12 @@ const (
// Module implements the ClientAPIModule interface for admin-related actions (reports, emojis, etc)
type Module struct {
config *config.Config
processor message.Processor
processor processing.Processor
log *logrus.Logger
}
// New returns a new admin module
func New(config *config.Config, processor message.Processor, log *logrus.Logger) api.ClientModule {
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule {
return &Module{
config: config,
processor: processor,

View File

@ -24,7 +24,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/router"
)
@ -34,12 +34,12 @@ const BasePath = "/api/v1/apps"
// Module implements the ClientAPIModule interface for requests relating to registering/removing applications
type Module struct {
config *config.Config
processor message.Processor
processor processing.Processor
log *logrus.Logger
}
// New returns a new auth module
func New(config *config.Config, processor message.Processor, log *logrus.Logger) api.ClientModule {
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule {
return &Module{
config: config,
processor: processor,

View File

@ -27,7 +27,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/router"
)
@ -46,13 +46,13 @@ const (
// The goal here is to serve requested media files if the gotosocial server is configured to use local storage.
type FileServer struct {
config *config.Config
processor message.Processor
processor processing.Processor
log *logrus.Logger
storageBase string
}
// New returns a new fileServer module
func New(config *config.Config, processor message.Processor, log *logrus.Logger) api.ClientModule {
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule {
return &FileServer{
config: config,
processor: processor,

View File

@ -31,14 +31,14 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/api/client/fileserver"
"github.com/superseriousbusiness/gotosocial/internal/blob"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/federation"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -49,10 +49,10 @@ type ServeFileTestSuite struct {
config *config.Config
db db.DB
log *logrus.Logger
storage storage.Storage
storage blob.Storage
federator federation.Federator
tc typeutils.TypeConverter
processor message.Processor
processor processing.Processor
mediaHandler media.Handler
oauthServer oauth.Server

View File

@ -24,7 +24,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/router"
)
@ -46,12 +46,12 @@ const (
// Module implements the ClientAPIModule interface for every related to interacting with follow requests
type Module struct {
config *config.Config
processor message.Processor
processor processing.Processor
log *logrus.Logger
}
// New returns a new follow request module
func New(config *config.Config, processor message.Processor, log *logrus.Logger) api.ClientModule {
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule {
return &Module{
config: config,
processor: processor,

View File

@ -6,7 +6,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/router"
)
@ -18,12 +18,12 @@ const (
// Module implements the ClientModule interface
type Module struct {
config *config.Config
processor message.Processor
processor processing.Processor
log *logrus.Logger
}
// New returns a new instance information module
func New(config *config.Config, processor message.Processor, log *logrus.Logger) api.ClientModule {
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule {
return &Module{
config: config,
processor: processor,

View File

@ -27,7 +27,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/router"
)
@ -43,12 +43,12 @@ const BasePathWithID = BasePath + "/:" + IDKey
// Module implements the ClientAPIModule interface for media
type Module struct {
config *config.Config
processor message.Processor
processor processing.Processor
log *logrus.Logger
}
// New returns a new auth module
func New(config *config.Config, processor message.Processor, log *logrus.Logger) api.ClientModule {
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule {
return &Module{
config: config,
processor: processor,

View File

@ -34,14 +34,14 @@ import (
"github.com/stretchr/testify/suite"
mediamodule "github.com/superseriousbusiness/gotosocial/internal/api/client/media"
"github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/blob"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/federation"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
"github.com/superseriousbusiness/gotosocial/testrig"
)
@ -52,12 +52,12 @@ type MediaCreateTestSuite struct {
config *config.Config
db db.DB
log *logrus.Logger
storage storage.Storage
storage blob.Storage
federator federation.Federator
tc typeutils.TypeConverter
mediaHandler media.Handler
oauthServer oauth.Server
processor message.Processor
processor processing.Processor
// standard suite models
testTokens map[string]*oauth.Token

View File

@ -24,7 +24,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/router"
)
@ -39,19 +39,19 @@ const (
// MaxIDKey is the url query for setting a max notification ID to return
MaxIDKey = "max_id"
// Limit key is for specifying maximum number of notifications to return.
// LimitKey is for specifying maximum number of notifications to return.
LimitKey = "limit"
)
// Module implements the ClientAPIModule interface for every related to posting/deleting/interacting with notifications
type Module struct {
config *config.Config
processor message.Processor
processor processing.Processor
log *logrus.Logger
}
// New returns a new notification module
func New(config *config.Config, processor message.Processor, log *logrus.Logger) api.ClientModule {
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule {
return &Module{
config: config,
processor: processor,

View File

@ -27,6 +27,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
// 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{
"func": "NotificationsGETHandler",

View File

@ -24,12 +24,12 @@ import (
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/router"
)
const (
// BasePath is the base path for serving v1 of the search API
// BasePathV1 is the base path for serving v1 of the search API
BasePathV1 = "/api/v1/search"
// BasePathV2 is the base path for serving v2 of the search API
@ -67,12 +67,12 @@ const (
// Module implements the ClientAPIModule interface for everything related to searching
type Module struct {
config *config.Config
processor message.Processor
processor processing.Processor
log *logrus.Logger
}
// New returns a new search module
func New(config *config.Config, processor message.Processor, log *logrus.Logger) api.ClientModule {
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule {
return &Module{
config: config,
processor: processor,

View File

@ -26,7 +26,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/router"
)
@ -75,12 +75,12 @@ const (
// Module implements the ClientAPIModule interface for every related to posting/deleting/interacting with statuses
type Module struct {
config *config.Config
processor message.Processor
processor processing.Processor
log *logrus.Logger
}
// New returns a new account module
func New(config *config.Config, processor message.Processor, log *logrus.Logger) api.ClientModule {
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule {
return &Module{
config: config,
processor: processor,

View File

@ -22,13 +22,13 @@ import (
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/api/client/status"
"github.com/superseriousbusiness/gotosocial/internal/blob"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/federation"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
)
@ -41,8 +41,8 @@ type StatusStandardTestSuite struct {
log *logrus.Logger
tc typeutils.TypeConverter
federator federation.Federator
processor message.Processor
storage storage.Storage
processor processing.Processor
storage blob.Storage
// standard suite models
testTokens map[string]*oauth.Token

View File

@ -24,7 +24,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/router"
)
@ -39,7 +39,7 @@ const (
SinceIDKey = "since_id"
// MinIDKey is the url query for returning results immediately newer than the given ID
MinIDKey = "min_id"
// Limit key is for specifying maximum number of results to return.
// LimitKey is for specifying maximum number of results to return.
LimitKey = "limit"
// LocalKey is for specifying whether only local statuses should be returned
LocalKey = "local"
@ -48,12 +48,12 @@ const (
// Module implements the ClientAPIModule interface for everything relating to viewing timelines
type Module struct {
config *config.Config
processor message.Processor
processor processing.Processor
log *logrus.Logger
}
// New returns a new timeline module
func New(config *config.Config, processor message.Processor, log *logrus.Logger) api.ClientModule {
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.ClientModule {
return &Module{
config: config,
processor: processor,

View File

@ -25,6 +25,7 @@ import (
"github.com/sirupsen/logrus"
)
// 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{
"func": "FollowersGETHandler",

View File

@ -25,6 +25,7 @@ import (
"github.com/sirupsen/logrus"
)
// 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{
"func": "FollowingGETHandler",

View File

@ -23,7 +23,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/processing"
)
// InboxPOSTHandler deals with incoming POST requests to an actor's inbox.
@ -42,7 +42,7 @@ func (m *Module) InboxPOSTHandler(c *gin.Context) {
posted, err := m.processor.InboxPost(c.Request.Context(), c.Writer, c.Request)
if err != nil {
if withCode, ok := err.(message.ErrorWithCode); ok {
if withCode, ok := err.(processing.ErrorWithCode); ok {
l.Debug(withCode.Error())
c.JSON(withCode.Code(), withCode.Safe())
return

View File

@ -7,6 +7,7 @@ import (
"github.com/sirupsen/logrus"
)
// 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{
"func": "StatusGETHandler",

View File

@ -24,7 +24,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/router"
"github.com/superseriousbusiness/gotosocial/internal/util"
)
@ -60,12 +60,12 @@ var ActivityPubAcceptHeaders = []string{
// Module implements the FederationAPIModule interface
type Module struct {
config *config.Config
processor message.Processor
processor processing.Processor
log *logrus.Logger
}
// New returns a new auth module
func New(config *config.Config, processor message.Processor, log *logrus.Logger) api.FederationModule {
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.FederationModule {
return &Module{
config: config,
processor: processor,

View File

@ -4,13 +4,13 @@ import (
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/api/s2s/user"
"github.com/superseriousbusiness/gotosocial/internal/blob"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/federation"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/storage"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
)
@ -23,8 +23,8 @@ type UserStandardTestSuite struct {
log *logrus.Logger
tc typeutils.TypeConverter
federator federation.Federator
processor message.Processor
storage storage.Storage
processor processing.Processor
storage blob.Storage
// standard suite models
testTokens map[string]*oauth.Token

View File

@ -24,7 +24,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/message"
"github.com/superseriousbusiness/gotosocial/internal/processing"
"github.com/superseriousbusiness/gotosocial/internal/router"
)
@ -36,12 +36,12 @@ const (
// Module implements the FederationModule interface
type Module struct {
config *config.Config
processor message.Processor
processor processing.Processor
log *logrus.Logger
}
// New returns a new webfinger module
func New(config *config.Config, processor message.Processor, log *logrus.Logger) api.FederationModule {
func New(config *config.Config, processor processing.Processor, log *logrus.Logger) api.FederationModule {
return &Module{
config: config,
processor: processor,