diff options
Diffstat (limited to 'internal/processing')
-rw-r--r-- | internal/processing/federation/getstatusreplies.go | 10 | ||||
-rw-r--r-- | internal/processing/federation/getuser.go | 7 | ||||
-rw-r--r-- | internal/processing/fromclientapi.go | 6 | ||||
-rw-r--r-- | internal/processing/fromfederator.go | 3 | ||||
-rw-r--r-- | internal/processing/status/util.go | 9 |
5 files changed, 16 insertions, 19 deletions
diff --git a/internal/processing/federation/getstatusreplies.go b/internal/processing/federation/getstatusreplies.go index 28c46269e..03fd734a6 100644 --- a/internal/processing/federation/getstatusreplies.go +++ b/internal/processing/federation/getstatusreplies.go @@ -82,10 +82,9 @@ func (p *processor) GetStatusReplies(ctx context.Context, requestedUsername stri // 1. we're asked for the whole collection and not a page -- we can just return the collection, with no items, but a link to 'first' page. // 2. we're asked for a page but only_other_accounts has not been set in the query -- so we should just return the first page of the collection, with no items. // 3. we're asked for a page, and only_other_accounts has been set, and min_id has optionally been set -- so we need to return some actual items! - - if !page { + switch { + case !page: // scenario 1 - // get the collection collection, err := p.tc.StatusToASRepliesCollection(ctx, s, onlyOtherAccounts) if err != nil { @@ -96,9 +95,8 @@ func (p *processor) GetStatusReplies(ctx context.Context, requestedUsername stri if err != nil { return nil, gtserror.NewErrorInternalError(err) } - } else if page && requestURL.Query().Get("only_other_accounts") == "" { + case page && requestURL.Query().Get("only_other_accounts") == "": // scenario 2 - // get the collection collection, err := p.tc.StatusToASRepliesCollection(ctx, s, onlyOtherAccounts) if err != nil { @@ -109,7 +107,7 @@ func (p *processor) GetStatusReplies(ctx context.Context, requestedUsername stri if err != nil { return nil, gtserror.NewErrorInternalError(err) } - } else { + default: // scenario 3 // get immediate children replies, err := p.db.GetStatusChildren(ctx, s, true, minID) diff --git a/internal/processing/federation/getuser.go b/internal/processing/federation/getuser.go index 37444bf5d..bde3d58de 100644 --- a/internal/processing/federation/getuser.go +++ b/internal/processing/federation/getuser.go @@ -38,13 +38,14 @@ func (p *processor) GetUser(ctx context.Context, requestedUsername string, reque } var requestedPerson vocab.ActivityStreamsPerson - if util.IsPublicKeyPath(requestURL) { + switch { + case util.IsPublicKeyPath(requestURL): // if it's a public key path, we don't need to authenticate but we'll only serve the bare minimum user profile needed for the public key requestedPerson, err = p.tc.AccountToASMinimal(ctx, requestedAccount) if err != nil { return nil, gtserror.NewErrorInternalError(err) } - } else if util.IsUserPath(requestURL) { + case util.IsUserPath(requestURL): // if it's a user path, we want to fully authenticate the request before we serve any data, and then we can serve a more complete profile requestingAccountURI, authenticated, err := p.federator.AuthenticateFederatedRequest(ctx, requestedUsername) if err != nil || !authenticated { @@ -72,7 +73,7 @@ func (p *processor) GetUser(ctx context.Context, requestedUsername string, reque if err != nil { return nil, gtserror.NewErrorInternalError(err) } - } else { + default: return nil, gtserror.NewErrorBadRequest(fmt.Errorf("path was not public key path or user path")) } diff --git a/internal/processing/fromclientapi.go b/internal/processing/fromclientapi.go index b8259c87a..e4810de40 100644 --- a/internal/processing/fromclientapi.go +++ b/internal/processing/fromclientapi.go @@ -64,15 +64,13 @@ func (p *processor) ProcessFromClientAPI(ctx context.Context, clientMsg messages } case ap.ActivityAccept: // ACCEPT - switch clientMsg.APObjectType { - case ap.ActivityFollow: + if clientMsg.APObjectType == ap.ActivityFollow { // ACCEPT FOLLOW return p.processAcceptFollowFromClientAPI(ctx, clientMsg) } case ap.ActivityReject: // REJECT - switch clientMsg.APObjectType { - case ap.ActivityFollow: + if clientMsg.APObjectType == ap.ActivityFollow { // REJECT FOLLOW (request) return p.processRejectFollowFromClientAPI(ctx, clientMsg) } diff --git a/internal/processing/fromfederator.go b/internal/processing/fromfederator.go index 243c0f3d7..2df5e39de 100644 --- a/internal/processing/fromfederator.go +++ b/internal/processing/fromfederator.go @@ -64,8 +64,7 @@ func (p *processor) ProcessFromFederator(ctx context.Context, federatorMsg messa } case ap.ActivityUpdate: // UPDATE SOMETHING - switch federatorMsg.APObjectType { - case ap.ObjectProfile: + if federatorMsg.APObjectType == ap.ObjectProfile { // UPDATE AN ACCOUNT return p.processUpdateAccountFromFederator(ctx, federatorMsg) } diff --git a/internal/processing/status/util.go b/internal/processing/status/util.go index e655632db..b9cd6aaba 100644 --- a/internal/processing/status/util.go +++ b/internal/processing/status/util.go @@ -38,14 +38,15 @@ func (p *processor) ProcessVisibility(ctx context.Context, form *apimodel.Advanc replyable := true likeable := true - var vis gtsmodel.Visibility // If visibility isn't set on the form, then just take the account default. // If that's also not set, take the default for the whole instance. - if form.Visibility != "" { + var vis gtsmodel.Visibility + switch { + case form.Visibility != "": vis = p.tc.APIVisToVis(form.Visibility) - } else if accountDefaultVis != "" { + case accountDefaultVis != "": vis = accountDefaultVis - } else { + default: vis = gtsmodel.VisibilityDefault } |