diff options
author | 2021-12-20 15:19:53 +0100 | |
---|---|---|
committer | 2021-12-20 15:19:53 +0100 | |
commit | cb8688f4298a1a3ed5e28565004588be3c071df0 (patch) | |
tree | 038b196e914b949857bf8b7c00f22374408bc1ca /internal/processing | |
parent | return first offer when no accept header set (#351) (diff) | |
download | gotosocial-cb8688f4298a1a3ed5e28565004588be3c071df0.tar.xz |
Remove unnecessary storage config variables (#344)
* rewire config to not use extraneous serve vars
* rename 'file' to 'local' for consistency
* use Type and Size again
Diffstat (limited to 'internal/processing')
-rw-r--r-- | internal/processing/account/createblock.go | 4 | ||||
-rw-r--r-- | internal/processing/account/createfollow.go | 4 | ||||
-rw-r--r-- | internal/processing/account/update.go | 4 | ||||
-rw-r--r-- | internal/processing/federation/getuser.go | 6 | ||||
-rw-r--r-- | internal/processing/federation/postinbox.go | 4 | ||||
-rw-r--r-- | internal/processing/media/getfile.go | 12 | ||||
-rw-r--r-- | internal/processing/status/create.go | 8 | ||||
-rw-r--r-- | internal/processing/status/fave.go | 4 | ||||
-rw-r--r-- | internal/processing/user/emailconfirm.go | 4 |
9 files changed, 25 insertions, 25 deletions
diff --git a/internal/processing/account/createblock.go b/internal/processing/account/createblock.go index 6785ffed1..bde3e00e7 100644 --- a/internal/processing/account/createblock.go +++ b/internal/processing/account/createblock.go @@ -29,7 +29,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/id" "github.com/superseriousbusiness/gotosocial/internal/messages" - "github.com/superseriousbusiness/gotosocial/internal/util" + "github.com/superseriousbusiness/gotosocial/internal/uris" ) func (p *processor) BlockCreate(ctx context.Context, requestingAccount *gtsmodel.Account, targetAccountID string) (*apimodel.Relationship, gtserror.WithCode) { @@ -57,7 +57,7 @@ func (p *processor) BlockCreate(ctx context.Context, requestingAccount *gtsmodel block.Account = requestingAccount block.TargetAccountID = targetAccountID block.TargetAccount = targetAccount - block.URI = util.GenerateURIForBlock(requestingAccount.Username, newBlockID) + block.URI = uris.GenerateURIForBlock(requestingAccount.Username, newBlockID) // whack it in the database if err := p.db.Put(ctx, block); err != nil { diff --git a/internal/processing/account/createfollow.go b/internal/processing/account/createfollow.go index 9b082187b..7abce9555 100644 --- a/internal/processing/account/createfollow.go +++ b/internal/processing/account/createfollow.go @@ -29,7 +29,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/id" "github.com/superseriousbusiness/gotosocial/internal/messages" - "github.com/superseriousbusiness/gotosocial/internal/util" + "github.com/superseriousbusiness/gotosocial/internal/uris" ) func (p *processor) FollowCreate(ctx context.Context, requestingAccount *gtsmodel.Account, form *apimodel.AccountFollowRequest) (*apimodel.Relationship, gtserror.WithCode) { @@ -76,7 +76,7 @@ func (p *processor) FollowCreate(ctx context.Context, requestingAccount *gtsmode AccountID: requestingAccount.ID, TargetAccountID: form.ID, ShowReblogs: true, - URI: util.GenerateURIForFollow(requestingAccount.Username, newFollowID), + URI: uris.GenerateURIForFollow(requestingAccount.Username, newFollowID), Notify: false, } if form.Reblogs != nil { diff --git a/internal/processing/account/update.go b/internal/processing/account/update.go index ca386eb39..9d34f4806 100644 --- a/internal/processing/account/update.go +++ b/internal/processing/account/update.go @@ -159,7 +159,7 @@ func (p *processor) UpdateAvatar(ctx context.Context, avatar *multipart.FileHead } // do the setting - avatarInfo, err := p.mediaHandler.ProcessHeaderOrAvatar(ctx, buf.Bytes(), accountID, media.Avatar, "") + avatarInfo, err := p.mediaHandler.ProcessHeaderOrAvatar(ctx, buf.Bytes(), accountID, media.TypeAvatar, "") if err != nil { return nil, fmt.Errorf("error processing avatar: %s", err) } @@ -193,7 +193,7 @@ func (p *processor) UpdateHeader(ctx context.Context, header *multipart.FileHead } // do the setting - headerInfo, err := p.mediaHandler.ProcessHeaderOrAvatar(ctx, buf.Bytes(), accountID, media.Header, "") + headerInfo, err := p.mediaHandler.ProcessHeaderOrAvatar(ctx, buf.Bytes(), accountID, media.TypeHeader, "") if err != nil { return nil, fmt.Errorf("error processing header: %s", err) } diff --git a/internal/processing/federation/getuser.go b/internal/processing/federation/getuser.go index bde3d58de..9f2201c1c 100644 --- a/internal/processing/federation/getuser.go +++ b/internal/processing/federation/getuser.go @@ -27,7 +27,7 @@ import ( "github.com/superseriousbusiness/activity/streams" "github.com/superseriousbusiness/activity/streams/vocab" "github.com/superseriousbusiness/gotosocial/internal/gtserror" - "github.com/superseriousbusiness/gotosocial/internal/util" + "github.com/superseriousbusiness/gotosocial/internal/uris" ) func (p *processor) GetUser(ctx context.Context, requestedUsername string, requestURL *url.URL) (interface{}, gtserror.WithCode) { @@ -39,13 +39,13 @@ func (p *processor) GetUser(ctx context.Context, requestedUsername string, reque var requestedPerson vocab.ActivityStreamsPerson switch { - case util.IsPublicKeyPath(requestURL): + case uris.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) } - case util.IsUserPath(requestURL): + case uris.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 { diff --git a/internal/processing/federation/postinbox.go b/internal/processing/federation/postinbox.go index df9da0a51..e2143bf46 100644 --- a/internal/processing/federation/postinbox.go +++ b/internal/processing/federation/postinbox.go @@ -22,11 +22,11 @@ import ( "context" "net/http" - "github.com/superseriousbusiness/gotosocial/internal/util" + "github.com/superseriousbusiness/gotosocial/internal/ap" ) func (p *processor) PostInbox(ctx context.Context, w http.ResponseWriter, r *http.Request) (bool, error) { // pass the fromFederator channel through to postInbox, since it'll be needed later - contextWithChannel := context.WithValue(ctx, util.APFromFederatorChanKey, p.fromFederator) + contextWithChannel := context.WithValue(ctx, ap.ContextFromFederatorChan, p.fromFederator) return p.federator.FederatingActor().PostInbox(contextWithChannel, w, r) } diff --git a/internal/processing/media/getfile.go b/internal/processing/media/getfile.go index 3cfdbe56b..52ea04484 100644 --- a/internal/processing/media/getfile.go +++ b/internal/processing/media/getfile.go @@ -72,7 +72,7 @@ func (p *processor) GetFile(ctx context.Context, account *gtsmodel.Account, form content := &apimodel.Content{} var storagePath string switch mediaType { - case media.Emoji: + case media.TypeEmoji: e := >smodel.Emoji{} if err := p.db.GetByID(ctx, wantedMediaID, e); err != nil { return nil, gtserror.NewErrorNotFound(fmt.Errorf("emoji %s could not be taken from the db: %s", wantedMediaID, err)) @@ -81,16 +81,16 @@ func (p *processor) GetFile(ctx context.Context, account *gtsmodel.Account, form return nil, gtserror.NewErrorNotFound(fmt.Errorf("emoji %s has been disabled", wantedMediaID)) } switch mediaSize { - case media.Original: + case media.SizeOriginal: content.ContentType = e.ImageContentType storagePath = e.ImagePath - case media.Static: + case media.SizeStatic: content.ContentType = e.ImageStaticContentType storagePath = e.ImageStaticPath default: return nil, gtserror.NewErrorNotFound(fmt.Errorf("media size %s not recognized for emoji", mediaSize)) } - case media.Attachment, media.Header, media.Avatar: + case media.TypeAttachment, media.TypeHeader, media.TypeAvatar: a, err := p.db.GetAttachmentByID(ctx, wantedMediaID) if err != nil { return nil, gtserror.NewErrorNotFound(fmt.Errorf("attachment %s could not be taken from the db: %s", wantedMediaID, err)) @@ -99,10 +99,10 @@ func (p *processor) GetFile(ctx context.Context, account *gtsmodel.Account, form return nil, gtserror.NewErrorNotFound(fmt.Errorf("attachment %s is not owned by %s", wantedMediaID, form.AccountID)) } switch mediaSize { - case media.Original: + case media.SizeOriginal: content.ContentType = a.File.ContentType storagePath = a.File.Path - case media.Small: + case media.SizeSmall: content.ContentType = a.Thumbnail.ContentType storagePath = a.Thumbnail.Path default: diff --git a/internal/processing/status/create.go b/internal/processing/status/create.go index 9bcb32b78..d1bd82b28 100644 --- a/internal/processing/status/create.go +++ b/internal/processing/status/create.go @@ -30,17 +30,17 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/id" "github.com/superseriousbusiness/gotosocial/internal/messages" "github.com/superseriousbusiness/gotosocial/internal/text" - "github.com/superseriousbusiness/gotosocial/internal/util" + "github.com/superseriousbusiness/gotosocial/internal/uris" ) func (p *processor) Create(ctx context.Context, account *gtsmodel.Account, application *gtsmodel.Application, form *apimodel.AdvancedStatusCreateForm) (*apimodel.Status, gtserror.WithCode) { - uris := util.GenerateURIsForAccount(account.Username) + accountURIs := uris.GenerateURIsForAccount(account.Username) thisStatusID, err := id.NewULID() if err != nil { return nil, gtserror.NewErrorInternalError(err) } - thisStatusURI := fmt.Sprintf("%s/%s", uris.StatusesURI, thisStatusID) - thisStatusURL := fmt.Sprintf("%s/%s", uris.StatusesURL, thisStatusID) + thisStatusURI := fmt.Sprintf("%s/%s", accountURIs.StatusesURI, thisStatusID) + thisStatusURL := fmt.Sprintf("%s/%s", accountURIs.StatusesURL, thisStatusID) newStatus := >smodel.Status{ ID: thisStatusID, diff --git a/internal/processing/status/fave.go b/internal/processing/status/fave.go index 581caf055..a044a2b58 100644 --- a/internal/processing/status/fave.go +++ b/internal/processing/status/fave.go @@ -30,7 +30,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/id" "github.com/superseriousbusiness/gotosocial/internal/messages" - "github.com/superseriousbusiness/gotosocial/internal/util" + "github.com/superseriousbusiness/gotosocial/internal/uris" ) func (p *processor) Fave(ctx context.Context, requestingAccount *gtsmodel.Account, targetStatusID string) (*apimodel.Status, gtserror.WithCode) { @@ -76,7 +76,7 @@ func (p *processor) Fave(ctx context.Context, requestingAccount *gtsmodel.Accoun TargetAccount: targetStatus.Account, StatusID: targetStatus.ID, Status: targetStatus, - URI: util.GenerateURIForLike(requestingAccount.Username, thisFaveID), + URI: uris.GenerateURIForLike(requestingAccount.Username, thisFaveID), } if err := p.db.Put(ctx, gtsFave); err != nil { diff --git a/internal/processing/user/emailconfirm.go b/internal/processing/user/emailconfirm.go index 3e19c61d4..4a588c395 100644 --- a/internal/processing/user/emailconfirm.go +++ b/internal/processing/user/emailconfirm.go @@ -31,7 +31,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/email" "github.com/superseriousbusiness/gotosocial/internal/gtserror" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" - "github.com/superseriousbusiness/gotosocial/internal/util" + "github.com/superseriousbusiness/gotosocial/internal/uris" ) var ( @@ -53,7 +53,7 @@ func (p *processor) SendConfirmEmail(ctx context.Context, user *gtsmodel.User, u // equivalent to the odds of creating a few tens of trillions of UUIDs in a // year and having one duplicate. confirmationToken := uuid.NewString() - confirmationLink := util.GenerateURIForEmailConfirm(confirmationToken) + confirmationLink := uris.GenerateURIForEmailConfirm(confirmationToken) // pull our instance entry from the database so we can greet the user nicely in the email instance := >smodel.Instance{} |