summaryrefslogtreecommitdiff
path: root/internal/transport
diff options
context:
space:
mode:
Diffstat (limited to 'internal/transport')
-rw-r--r--internal/transport/controller.go14
-rw-r--r--internal/transport/deliver.go3
-rw-r--r--internal/transport/dereference.go3
3 files changed, 7 insertions, 13 deletions
diff --git a/internal/transport/controller.go b/internal/transport/controller.go
index 280d4bc0b..45eb4fd79 100644
--- a/internal/transport/controller.go
+++ b/internal/transport/controller.go
@@ -25,13 +25,11 @@ import (
"encoding/json"
"fmt"
"net/url"
- "runtime/debug"
"time"
"codeberg.org/gruf/go-byteutil"
"codeberg.org/gruf/go-cache/v2"
"github.com/sirupsen/logrus"
- "github.com/spf13/viper"
"github.com/superseriousbusiness/activity/pub"
"github.com/superseriousbusiness/activity/streams"
"github.com/superseriousbusiness/gotosocial/internal/config"
@@ -59,11 +57,9 @@ type controller struct {
// NewController returns an implementation of the Controller interface for creating new transports
func NewController(db db.DB, federatingDB federatingdb.DB, clock pub.Clock, client pub.HttpClient) Controller {
- applicationName := viper.GetString(config.Keys.ApplicationName)
- host := viper.GetString(config.Keys.Host)
-
- // Determine build information
- build, _ := debug.ReadBuildInfo()
+ applicationName := config.GetApplicationName()
+ host := config.GetHost()
+ version := config.GetSoftwareVersion()
c := &controller{
db: db,
@@ -71,7 +67,7 @@ func NewController(db db.DB, federatingDB federatingdb.DB, clock pub.Clock, clie
clock: clock,
client: client,
cache: cache.New[string, *transport](),
- userAgent: fmt.Sprintf("%s; %s (gofed/activity gotosocial-%s)", applicationName, host, build.Main.Version),
+ userAgent: fmt.Sprintf("%s; %s (gofed/activity gotosocial-%s)", applicationName, host, version),
}
// Transport cache has TTL=1hr freq=1m
@@ -128,7 +124,7 @@ func (c *controller) NewTransportForUsername(ctx context.Context, username strin
// Otherwise, we can take the instance account and use those credentials to make the request.
var u string
if username == "" {
- u = viper.GetString(config.Keys.Host)
+ u = config.GetHost()
} else {
u = username
}
diff --git a/internal/transport/deliver.go b/internal/transport/deliver.go
index bacaa9b3a..0405116ad 100644
--- a/internal/transport/deliver.go
+++ b/internal/transport/deliver.go
@@ -27,7 +27,6 @@ import (
"strings"
"sync"
- "github.com/spf13/viper"
"github.com/superseriousbusiness/gotosocial/internal/config"
)
@@ -69,7 +68,7 @@ outer:
func (t *transport) Deliver(ctx context.Context, b []byte, to *url.URL) error {
// if the 'to' host is our own, just skip this delivery since we by definition already have the message!
- if to.Host == viper.GetString(config.Keys.Host) || to.Host == viper.GetString(config.Keys.AccountDomain) {
+ if to.Host == config.GetHost() || to.Host == config.GetAccountDomain() {
return nil
}
diff --git a/internal/transport/dereference.go b/internal/transport/dereference.go
index 3d252525b..ba48488d7 100644
--- a/internal/transport/dereference.go
+++ b/internal/transport/dereference.go
@@ -25,7 +25,6 @@ import (
"net/http"
"net/url"
- "github.com/spf13/viper"
"github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/uris"
)
@@ -33,7 +32,7 @@ import (
func (t *transport) Dereference(ctx context.Context, iri *url.URL) ([]byte, error) {
// if the request is to us, we can shortcut for certain URIs rather than going through
// the normal request flow, thereby saving time and energy
- if iri.Host == viper.GetString(config.Keys.Host) {
+ if iri.Host == config.GetHost() {
if uris.IsFollowersPath(iri) {
// the request is for followers of one of our accounts, which we can shortcut
return t.controller.dereferenceLocalFollowers(ctx, iri)