diff options
Diffstat (limited to 'internal/processing')
-rw-r--r-- | internal/processing/account/create.go | 6 | ||||
-rw-r--r-- | internal/processing/account/update.go | 5 | ||||
-rw-r--r-- | internal/processing/blocks.go | 5 | ||||
-rw-r--r-- | internal/processing/federation/getnodeinfo.go | 9 | ||||
-rw-r--r-- | internal/processing/federation/getwebfinger.go | 5 | ||||
-rw-r--r-- | internal/processing/instance.go | 3 | ||||
-rw-r--r-- | internal/processing/search.go | 4 | ||||
-rw-r--r-- | internal/processing/statustimeline.go | 9 | ||||
-rw-r--r-- | internal/processing/user/emailconfirm.go | 7 |
9 files changed, 20 insertions, 33 deletions
diff --git a/internal/processing/account/create.go b/internal/processing/account/create.go index 61c4f95ef..72626220b 100644 --- a/internal/processing/account/create.go +++ b/internal/processing/account/create.go @@ -23,7 +23,6 @@ import ( "fmt" "github.com/sirupsen/logrus" - "github.com/spf13/viper" "github.com/superseriousbusiness/gotosocial/internal/ap" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" @@ -53,9 +52,8 @@ func (p *processor) Create(ctx context.Context, applicationToken oauth2.TokenInf return nil, fmt.Errorf("username %s in use", form.Username) } - keys := config.Keys - reasonRequired := viper.GetBool(keys.AccountsReasonRequired) - approvalRequired := viper.GetBool(keys.AccountsApprovalRequired) + reasonRequired := config.GetAccountsReasonRequired() + approvalRequired := config.GetAccountsApprovalRequired() // don't store a reason if we don't require one reason := form.Reason diff --git a/internal/processing/account/update.go b/internal/processing/account/update.go index 5fae6e73b..42da40ffe 100644 --- a/internal/processing/account/update.go +++ b/internal/processing/account/update.go @@ -25,7 +25,6 @@ import ( "mime/multipart" "github.com/sirupsen/logrus" - "github.com/spf13/viper" "github.com/superseriousbusiness/gotosocial/internal/ap" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" @@ -142,7 +141,7 @@ func (p *processor) Update(ctx context.Context, account *gtsmodel.Account, form // parsing and checking the image, and doing the necessary updates in the database for this to become // the account's new avatar image. func (p *processor) UpdateAvatar(ctx context.Context, avatar *multipart.FileHeader, accountID string) (*gtsmodel.MediaAttachment, error) { - maxImageSize := viper.GetInt(config.Keys.MediaImageMaxSize) + maxImageSize := config.GetMediaImageMaxSize() if int(avatar.Size) > maxImageSize { return nil, fmt.Errorf("UpdateAvatar: avatar with size %d exceeded max image size of %d bytes", avatar.Size, maxImageSize) } @@ -169,7 +168,7 @@ func (p *processor) UpdateAvatar(ctx context.Context, avatar *multipart.FileHead // parsing and checking the image, and doing the necessary updates in the database for this to become // the account's new header image. func (p *processor) UpdateHeader(ctx context.Context, header *multipart.FileHeader, accountID string) (*gtsmodel.MediaAttachment, error) { - maxImageSize := viper.GetInt(config.Keys.MediaImageMaxSize) + maxImageSize := config.GetMediaImageMaxSize() if int(header.Size) > maxImageSize { return nil, fmt.Errorf("UpdateHeader: header with size %d exceeded max image size of %d bytes", header.Size, maxImageSize) } diff --git a/internal/processing/blocks.go b/internal/processing/blocks.go index 2700d4d3b..6a4c949a4 100644 --- a/internal/processing/blocks.go +++ b/internal/processing/blocks.go @@ -23,7 +23,6 @@ import ( "fmt" "net/url" - "github.com/spf13/viper" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/db" @@ -64,8 +63,8 @@ func (p *processor) packageBlocksResponse(accounts []*apimodel.Account, path str // prepare the next and previous links if len(accounts) != 0 { - protocol := viper.GetString(config.Keys.Protocol) - host := viper.GetString(config.Keys.Host) + protocol := config.GetProtocol() + host := config.GetHost() nextLink := &url.URL{ Scheme: protocol, diff --git a/internal/processing/federation/getnodeinfo.go b/internal/processing/federation/getnodeinfo.go index 46792d22a..c4aebe57d 100644 --- a/internal/processing/federation/getnodeinfo.go +++ b/internal/processing/federation/getnodeinfo.go @@ -23,7 +23,6 @@ import ( "fmt" "net/http" - "github.com/spf13/viper" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/gtserror" @@ -40,8 +39,8 @@ var ( ) func (p *processor) GetNodeInfoRel(ctx context.Context, request *http.Request) (*apimodel.WellKnownResponse, gtserror.WithCode) { - protocol := viper.GetString(config.Keys.Protocol) - host := viper.GetString(config.Keys.Host) + protocol := config.GetProtocol() + host := config.GetHost() return &apimodel.WellKnownResponse{ Links: []apimodel.Link{ @@ -54,8 +53,8 @@ func (p *processor) GetNodeInfoRel(ctx context.Context, request *http.Request) ( } func (p *processor) GetNodeInfo(ctx context.Context, request *http.Request) (*apimodel.Nodeinfo, gtserror.WithCode) { - openRegistration := viper.GetBool(config.Keys.AccountsRegistrationOpen) - softwareVersion := viper.GetString(config.Keys.SoftwareVersion) + openRegistration := config.GetAccountsRegistrationOpen() + softwareVersion := config.GetSoftwareVersion() return &apimodel.Nodeinfo{ Version: nodeInfoVersion, diff --git a/internal/processing/federation/getwebfinger.go b/internal/processing/federation/getwebfinger.go index cbc4a7ebc..7158680d7 100644 --- a/internal/processing/federation/getwebfinger.go +++ b/internal/processing/federation/getwebfinger.go @@ -22,7 +22,6 @@ import ( "context" "fmt" - "github.com/spf13/viper" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/gtserror" @@ -43,9 +42,9 @@ func (p *processor) GetWebfingerAccount(ctx context.Context, requestedUsername s return nil, gtserror.NewErrorNotFound(fmt.Errorf("database error getting account with username %s: %s", requestedUsername, err)) } - accountDomain := viper.GetString(config.Keys.AccountDomain) + accountDomain := config.GetAccountDomain() if accountDomain == "" { - accountDomain = viper.GetString(config.Keys.Host) + accountDomain = config.GetHost() } // return the webfinger representation diff --git a/internal/processing/instance.go b/internal/processing/instance.go index f4fe2ca79..ab601d3b3 100644 --- a/internal/processing/instance.go +++ b/internal/processing/instance.go @@ -22,7 +22,6 @@ import ( "context" "fmt" - "github.com/spf13/viper" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/db" @@ -49,7 +48,7 @@ func (p *processor) InstanceGet(ctx context.Context, domain string) (*apimodel.I func (p *processor) InstancePatch(ctx context.Context, form *apimodel.InstanceSettingsUpdateRequest) (*apimodel.Instance, gtserror.WithCode) { // fetch the instance entry from the db for processing i := >smodel.Instance{} - host := viper.GetString(config.Keys.Host) + host := config.GetHost() if err := p.db.GetWhere(ctx, []db.Where{{Key: "domain", Value: host}}, i); err != nil { return nil, gtserror.NewErrorInternalError(fmt.Errorf("db error fetching instance %s: %s", host, err)) } diff --git a/internal/processing/search.go b/internal/processing/search.go index 690a6eeaf..1b0813fd9 100644 --- a/internal/processing/search.go +++ b/internal/processing/search.go @@ -25,7 +25,6 @@ import ( "strings" "github.com/sirupsen/logrus" - "github.com/spf13/viper" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/db" @@ -166,8 +165,7 @@ func (p *processor) searchAccountByMention(ctx context.Context, authed *oauth.Au // if it's a local account we can skip a whole bunch of stuff maybeAcct := >smodel.Account{} - host := viper.GetString(config.Keys.Host) - if domain == host { + if domain == config.GetHost() { maybeAcct, err = p.db.GetLocalAccountByUsername(ctx, username) if err != nil { return nil, fmt.Errorf("searchAccountByMention: error getting local account by username: %s", err) diff --git a/internal/processing/statustimeline.go b/internal/processing/statustimeline.go index 355825900..d4388f381 100644 --- a/internal/processing/statustimeline.go +++ b/internal/processing/statustimeline.go @@ -25,7 +25,6 @@ import ( "net/url" "github.com/sirupsen/logrus" - "github.com/spf13/viper" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" "github.com/superseriousbusiness/gotosocial/internal/config" @@ -111,8 +110,8 @@ func StatusSkipInsertFunction() timeline.SkipInsertFunction { nextItemAccountID string, nextItemBoostOfID string, nextItemBoostOfAccountID string, - depth int) (bool, error) { - + depth int, + ) (bool, error) { // make sure we don't insert a duplicate if newItemID == nextItemID { return true, nil @@ -148,8 +147,8 @@ func (p *processor) packageStatusResponse(statuses []*apimodel.Status, path stri // prepare the next and previous links if len(statuses) != 0 { - protocol := viper.GetString(config.Keys.Protocol) - host := viper.GetString(config.Keys.Host) + protocol := config.GetProtocol() + host := config.GetHost() nextLink := &url.URL{ Scheme: protocol, diff --git a/internal/processing/user/emailconfirm.go b/internal/processing/user/emailconfirm.go index e44a4605f..eccaae5ec 100644 --- a/internal/processing/user/emailconfirm.go +++ b/internal/processing/user/emailconfirm.go @@ -25,7 +25,6 @@ import ( "time" "github.com/google/uuid" - "github.com/spf13/viper" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/email" @@ -34,9 +33,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/uris" ) -var ( - oneWeek = 168 * time.Hour -) +var oneWeek = 168 * time.Hour func (p *processor) SendConfirmEmail(ctx context.Context, user *gtsmodel.User, username string) error { if user.UnconfirmedEmail == "" || user.UnconfirmedEmail == user.Email { @@ -57,7 +54,7 @@ func (p *processor) SendConfirmEmail(ctx context.Context, user *gtsmodel.User, u // pull our instance entry from the database so we can greet the user nicely in the email instance := >smodel.Instance{} - host := viper.GetString(config.Keys.Host) + host := config.GetHost() if err := p.db.GetWhere(ctx, []db.Where{{Key: "domain", Value: host}}, instance); err != nil { return fmt.Errorf("SendConfirmEmail: error getting instance: %s", err) } |