From 762dfe4b7ea256f87e035c3d4927631ec966fbb9 Mon Sep 17 00:00:00 2001 From: tsmethurst Date: Fri, 21 May 2021 23:03:55 +0200 Subject: [PATCH] Go fmt ./... --- internal/api/client/auth/middleware.go | 2 +- internal/db/db.go | 4 +- internal/message/fediprocess.go | 66 ++++++++++++------------ internal/message/fromcommonprocess.go | 2 +- internal/message/frprocess.go | 4 +- internal/typeutils/internaltoas.go | 2 +- internal/typeutils/internaltofrontend.go | 24 ++++----- 7 files changed, 53 insertions(+), 51 deletions(-) diff --git a/internal/api/client/auth/middleware.go b/internal/api/client/auth/middleware.go index dba8e5a1d..a734b2ceb 100644 --- a/internal/api/client/auth/middleware.go +++ b/internal/api/client/auth/middleware.go @@ -69,7 +69,7 @@ func (m *Module) OauthTokenMiddleware(c *gin.Context) { if cid := ti.GetClientID(); cid != "" { l.Tracef("authenticated client %s with bearer token, scope is %s", cid, ti.GetScope()) app := >smodel.Application{} - if err := m.db.GetWhere([]db.Where{{Key: "client_id",Value: cid}}, app); err != nil { + if err := m.db.GetWhere([]db.Where{{Key: "client_id", Value: cid}}, app); err != nil { l.Tracef("no app found for client %s", cid) } c.Set(oauth.SessionAuthorizedApplication, app) diff --git a/internal/db/db.go b/internal/db/db.go index b5b2511d9..e43318c58 100644 --- a/internal/db/db.go +++ b/internal/db/db.go @@ -32,18 +32,20 @@ const ( // ErrNoEntries is to be returned from the DB interface when no entries are found for a given query. type ErrNoEntries struct{} + func (e ErrNoEntries) Error() string { return "no entries" } // ErrAlreadyExists is to be returned from the DB interface when an entry already exists for a given query or its constraints. type ErrAlreadyExists struct{} + func (e ErrAlreadyExists) Error() string { return "already exists" } type Where struct { - Key string + Key string Value interface{} } diff --git a/internal/message/fediprocess.go b/internal/message/fediprocess.go index eb6e8b6d6..491997bf2 100644 --- a/internal/message/fediprocess.go +++ b/internal/message/fediprocess.go @@ -164,46 +164,46 @@ func (p *processor) GetFediFollowers(requestedUsername string, request *http.Req } func (p *processor) GetFediStatus(requestedUsername string, requestedStatusID string, request *http.Request) (interface{}, ErrorWithCode) { - // get the account the request is referring to - requestedAccount := >smodel.Account{} - if err := p.db.GetLocalAccountByUsername(requestedUsername, requestedAccount); err != nil { - return nil, NewErrorNotFound(fmt.Errorf("database error getting account with username %s: %s", requestedUsername, err)) - } + // get the account the request is referring to + requestedAccount := >smodel.Account{} + if err := p.db.GetLocalAccountByUsername(requestedUsername, requestedAccount); err != nil { + return nil, NewErrorNotFound(fmt.Errorf("database error getting account with username %s: %s", requestedUsername, err)) + } - // authenticate the request - requestingAccount, err := p.authenticateAndDereferenceFediRequest(requestedUsername, request) - if err != nil { - return nil, NewErrorNotAuthorized(err) - } + // authenticate the request + requestingAccount, err := p.authenticateAndDereferenceFediRequest(requestedUsername, request) + if err != nil { + return nil, NewErrorNotAuthorized(err) + } - blocked, err := p.db.Blocked(requestedAccount.ID, requestingAccount.ID) - if err != nil { - return nil, NewErrorInternalError(err) - } + blocked, err := p.db.Blocked(requestedAccount.ID, requestingAccount.ID) + if err != nil { + return nil, NewErrorInternalError(err) + } - if blocked { - return nil, NewErrorNotAuthorized(fmt.Errorf("block exists between accounts %s and %s", requestedAccount.ID, requestingAccount.ID)) - } + if blocked { + return nil, NewErrorNotAuthorized(fmt.Errorf("block exists between accounts %s and %s", requestedAccount.ID, requestingAccount.ID)) + } - s := >smodel.Status{} - if err := p.db.GetWhere([]db.Where{ - {Key: "id", Value: requestedStatusID}, - {Key: "account_id", Value: requestedAccount.ID}, - }, s); err != nil { - return nil, NewErrorNotFound(fmt.Errorf("database error getting status with id %s and account id %s: %s", requestedStatusID, requestedAccount.ID, err)) - } + s := >smodel.Status{} + if err := p.db.GetWhere([]db.Where{ + {Key: "id", Value: requestedStatusID}, + {Key: "account_id", Value: requestedAccount.ID}, + }, s); err != nil { + return nil, NewErrorNotFound(fmt.Errorf("database error getting status with id %s and account id %s: %s", requestedStatusID, requestedAccount.ID, err)) + } - asStatus, err := p.tc.StatusToAS(s) - if err != nil { - return nil, NewErrorInternalError(err) - } + asStatus, err := p.tc.StatusToAS(s) + if err != nil { + return nil, NewErrorInternalError(err) + } - data, err := streams.Serialize(asStatus) - if err != nil { - return nil, NewErrorInternalError(err) - } + data, err := streams.Serialize(asStatus) + if err != nil { + return nil, NewErrorInternalError(err) + } - return data, nil + return data, nil } func (p *processor) GetWebfingerAccount(requestedUsername string, request *http.Request) (*apimodel.WebfingerAccountResponse, ErrorWithCode) { diff --git a/internal/message/fromcommonprocess.go b/internal/message/fromcommonprocess.go index d557b7962..486da39af 100644 --- a/internal/message/fromcommonprocess.go +++ b/internal/message/fromcommonprocess.go @@ -25,5 +25,5 @@ func (p *processor) notifyStatus(status *gtsmodel.Status) error { } func (p *processor) notifyFollow(follow *gtsmodel.Follow) error { - return nil + return nil } diff --git a/internal/message/frprocess.go b/internal/message/frprocess.go index fd64b4c50..e229dcfbb 100644 --- a/internal/message/frprocess.go +++ b/internal/message/frprocess.go @@ -56,7 +56,7 @@ func (p *processor) FollowRequestAccept(auth *oauth.Auth, accountID string) (*ap p.fromClientAPI <- gtsmodel.FromClientAPI{ APActivityType: gtsmodel.ActivityStreamsAccept, - GTSModel: follow, + GTSModel: follow, } gtsR, err := p.db.GetRelationship(auth.Account.ID, accountID) @@ -65,7 +65,7 @@ func (p *processor) FollowRequestAccept(auth *oauth.Auth, accountID string) (*ap } r, err := p.tc.RelationshipToMasto(gtsR) - if err != nil { + if err != nil { return nil, NewErrorInternalError(err) } diff --git a/internal/typeutils/internaltoas.go b/internal/typeutils/internaltoas.go index 072c4e690..b7056ccbe 100644 --- a/internal/typeutils/internaltoas.go +++ b/internal/typeutils/internaltoas.go @@ -439,7 +439,7 @@ func (c *converter) StatusToAS(s *gtsmodel.Status) (vocab.ActivityStreamsNote, e // replies // TODO - + return status, nil } diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index 70f8a8d3c..1fd1577f9 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -575,18 +575,18 @@ func (c *converter) InstanceToMasto(i *gtsmodel.Instance) (*model.Instance, erro func (c *converter) RelationshipToMasto(r *gtsmodel.Relationship) (*model.Relationship, error) { return &model.Relationship{ - ID: r.ID, - Following: r.Following, - ShowingReblogs: r.ShowingReblogs, - Notifying: r.Notifying, - FollowedBy: r.FollowedBy, - Blocking: r.Blocking, - BlockedBy: r.BlockedBy, - Muting: r.Muting, + ID: r.ID, + Following: r.Following, + ShowingReblogs: r.ShowingReblogs, + Notifying: r.Notifying, + FollowedBy: r.FollowedBy, + Blocking: r.Blocking, + BlockedBy: r.BlockedBy, + Muting: r.Muting, MutingNotifications: r.MutingNotifications, - Requested: r.Requested, - DomainBlocking: r.DomainBlocking, - Endorsed: r.Endorsed, - Note: r.Note, + Requested: r.Requested, + DomainBlocking: r.DomainBlocking, + Endorsed: r.Endorsed, + Note: r.Note, }, nil }