fmt + lint

This commit is contained in:
tsmethurst 2021-05-15 11:53:38 +02:00
commit a602a3d9d2
21 changed files with 51 additions and 22 deletions

View file

@ -25,6 +25,8 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
// 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")
authed, err := oauth.Authed(c, true, true, true, true)

View file

@ -20,6 +20,8 @@ package followrequest
import "github.com/gin-gonic/gin"
// FollowRequestDenyPOSTHandler deals with follow request rejection. It should be served at
// /api/v1/follow_requests/:id/reject
func (m *Module) FollowRequestDenyPOSTHandler(c *gin.Context) {
}

View file

@ -25,6 +25,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/oauth"
)
// 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")
authed, err := oauth.Authed(c, true, true, true, true)

View file

@ -11,7 +11,7 @@ import (
)
const (
// InstanceInformationPath
// InstanceInformationPath is for serving instance info requests
InstanceInformationPath = "api/v1/instance"
)

View file

@ -6,6 +6,7 @@ import (
"github.com/gin-gonic/gin"
)
// InstanceInformationGETHandler is for serving instance information at /api/v1/instance
func (m *Module) InstanceInformationGETHandler(c *gin.Context) {
l := m.log.WithField("func", "InstanceInformationGETHandler")

View file

@ -33,8 +33,10 @@ import (
// BasePath is the base API path for making media requests
const BasePath = "/api/v1/media"
// IDKey is the key for media attachment IDs
const IDKey = "id"
// BasePathWithID corresponds to a media attachment with the given ID
const BasePathWithID = BasePath + "/:" + IDKey

View file

@ -43,7 +43,7 @@ func (m *Module) MediaGETHandler(c *gin.Context) {
attachment, errWithCode := m.processor.MediaGet(authed, attachmentID)
if errWithCode != nil {
c.JSON(errWithCode.Code(),gin.H{"error": errWithCode.Safe()})
c.JSON(errWithCode.Code(), gin.H{"error": errWithCode.Safe()})
return
}

View file

@ -28,7 +28,7 @@ type AttachmentRequest struct {
Focus string `form:"focus"`
}
// AttachmentRequest represents the form data parameters submitted by a client during a media update/PUT request.
// AttachmentUpdateRequest represents the form data parameters submitted by a client during a media update/PUT request.
// See: https://docs.joinmastodon.org/methods/statuses/media/
type AttachmentUpdateRequest struct {
Description *string `form:"description" json:"description" xml:"description"`

View file

@ -119,11 +119,15 @@ const (
VisibilityDirect Visibility = "direct"
)
// AdvancedStatusCreateForm wraps the mastodon status create form along with the GTS advanced
// visibility settings.
type AdvancedStatusCreateForm struct {
StatusCreateRequest
AdvancedVisibilityFlagsForm
}
// AdvancedVisibilityFlagsForm allows a few more advanced flags to be set on new statuses, in addition
// to the standard mastodon-compatible ones.
type AdvancedVisibilityFlagsForm struct {
// The gotosocial visibility model
VisibilityAdvanced *string `form:"visibility_advanced"`

View file

@ -26,6 +26,8 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/message"
)
// 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{
"func": "InboxPOSTHandler",

View file

@ -38,6 +38,7 @@ const (
// Use this anywhere you need to know the username of the user being queried.
// Eg https://example.org/users/:username
UsersBasePathWithUsername = UsersBasePath + "/:" + UsernameKey
// UsersInboxPath is for serving POST requests to a user's inbox with the given username key.
UsersInboxPath = UsersBasePathWithUsername + "/" + util.InboxPath
)

View file

@ -29,7 +29,7 @@ import (
)
const (
// The base path for serving webfinger lookup requests
// WebfingerBasePath is the base path for serving webfinger lookup requests
WebfingerBasePath = ".well-known/webfinger"
)

View file

@ -26,7 +26,10 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
)
const DBTypePostgres string = "POSTGRES"
const (
// DBTypePostgres represents an underlying POSTGRES database type.
DBTypePostgres string = "POSTGRES"
)
// ErrNoEntries is to be returned from the DB interface when no entries are found for a given query.
type ErrNoEntries struct{}
@ -112,6 +115,8 @@ type DB interface {
HANDY SHORTCUTS
*/
// AcceptFollowRequest moves a follow request in the database from the follow_requests table to the follows table.
// In other words, it should create the follow, and delete the existing follow request.
AcceptFollowRequest(originAccountID string, targetAccountID string) error
// CreateInstanceAccount creates an account in the database with the same username as the instance host value.
@ -150,6 +155,9 @@ type DB interface {
// In case of no entries, a 'no entries' error will be returned
GetFollowersByAccountID(accountID string, followers *[]gtsmodel.Follow) error
// GetFavesByAccountID is a shortcut for the common action of fetching a list of faves made by the given accountID.
// The given slice 'faves' will be set to the result of the query, whatever it is.
// In case of no entries, a 'no entries' error will be returned
GetFavesByAccountID(accountID string, faves *[]gtsmodel.StatusFave) error
// GetStatusesByAccountID is a shortcut for the common action of fetching a list of statuses produced by accountID.

View file

@ -37,6 +37,7 @@ func (c *Clock) Now() time.Time {
return time.Now()
}
// NewClock returns a simple pub.Clock for use in federation interfaces.
func NewClock() pub.Clock {
return &Clock{}
}

View file

@ -47,6 +47,7 @@ type federatingDB struct {
typeConverter typeutils.TypeConverter
}
// NewFederatingDB returns a pub.Database interface using the given database, config, and logger.
func NewFederatingDB(db db.DB, config *config.Config, log *logrus.Logger) pub.Database {
return &federatingDB{
locks: new(sync.Map),

View file

@ -95,6 +95,7 @@ type Mentionable interface {
withHref
}
// Followable represents the minimum interface for an activitystreams 'follow' activity.
type Followable interface {
withJSONLDId
withTypeName

View file

@ -24,6 +24,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/transport"
)
// NewTestFederator returns a federator with the given database and (mock!!) transport controller.
func NewTestFederator(db db.DB, tc transport.Controller) federation.Federator {
return federation.NewFederator(db, tc, NewTestConfig(), NewTestLog(), NewTestTypeConverter(db))
}

View file

@ -1037,6 +1037,7 @@ func NewTestFaves() map[string]*gtsmodel.StatusFave {
}
}
// ActivityWithSignature wraps a pub.Activity along with its signature headers, for testing.
type ActivityWithSignature struct {
Activity pub.Activity
SignatureHeader string
@ -1076,11 +1077,11 @@ func NewTestActivities(accounts map[string]*gtsmodel.Account) map[string]Activit
// NewTestFediPeople returns a bunch of activity pub Person representations for testing converters and so on.
func NewTestFediPeople() map[string]typeutils.Accountable {
new_person_1priv, err := rsa.GenerateKey(rand.Reader, 2048)
newPerson1Priv, err := rsa.GenerateKey(rand.Reader, 2048)
if err != nil {
panic(err)
}
new_person_1pub := &new_person_1priv.PublicKey
newPerson1Pub := &newPerson1Priv.PublicKey
return map[string]typeutils.Accountable{
"new_person_1": newPerson(
@ -1096,7 +1097,7 @@ func NewTestFediPeople() map[string]typeutils.Accountable {
URLMustParse("https://unknown-instance.com/@brand_new_person"),
true,
URLMustParse("https://unknown-instance.com/users/brand_new_person#main-key"),
new_person_1pub,
newPerson1Pub,
URLMustParse("https://unknown-instance.com/media/some_avatar_filename.jpeg"),
"image/jpeg",
URLMustParse("https://unknown-instance.com/media/some_header_filename.jpeg"),
@ -1105,6 +1106,7 @@ func NewTestFediPeople() map[string]typeutils.Accountable {
}
}
// NewTestDereferenceRequests returns a map of incoming dereference requests, with their signatures.
func NewTestDereferenceRequests(accounts map[string]*gtsmodel.Account) map[string]ActivityWithSignature {
sig, digest, date := getSignatureForDereference(accounts["remote_account_1"].PublicKeyURI, accounts["remote_account_1"].PrivateKey, URLMustParse(accounts["local_account_1"].URI))
return map[string]ActivityWithSignature{