summaryrefslogtreecommitdiff
path: root/internal/transport/controller.go
diff options
context:
space:
mode:
authorLibravatar Daenney <daenney@users.noreply.github.com>2023-03-08 13:57:41 +0100
committerLibravatar GitHub <noreply@github.com>2023-03-08 12:57:41 +0000
commite397272fe8550e4f81958d5d00bf3233e1bd0bfc (patch)
tree156bc2ebc49563a1ed3decd2171bf2da21b071cf /internal/transport/controller.go
parent[chore] Update uptrace/bun and modernc/sqlite dependencies (#1598) (diff)
downloadgotosocial-e397272fe8550e4f81958d5d00bf3233e1bd0bfc.tar.xz
[feature] Discover webfinger through host-meta (#1588)
* [feature] Discover webfinger through host-meta This implements a fallback for discovering the webfinger endpoint in case the /.well-known/webfinger endpoint wasn't properly redirected. Some instances do this because the recommendation used to be to use host-meta for the webfinger redirect in the before times. Closes #1558. * [bug] Ensure we only ever update cache on success * [chore] Move finger tests to their own place This adds a test suite for transport and moves the finger cache tests into there instead of abusing the search test suite. * [chore] cleanup the test a bit more We don't really need a separate function for the oddly located webfinger response as we check the full URL string anyway * Address review comments * [chore] update config example * [chore] access DB only through state in controller
Diffstat (limited to 'internal/transport/controller.go')
-rw-r--r--internal/transport/controller.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/internal/transport/controller.go b/internal/transport/controller.go
index abcccfe1e..d23ae0b68 100644
--- a/internal/transport/controller.go
+++ b/internal/transport/controller.go
@@ -32,9 +32,9 @@ import (
"github.com/superseriousbusiness/activity/pub"
"github.com/superseriousbusiness/activity/streams"
"github.com/superseriousbusiness/gotosocial/internal/config"
- "github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/federation/federatingdb"
"github.com/superseriousbusiness/gotosocial/internal/log"
+ "github.com/superseriousbusiness/gotosocial/internal/state"
)
// Controller generates transports for use in making federation requests to other servers.
@@ -47,7 +47,7 @@ type Controller interface {
}
type controller struct {
- db db.DB
+ state *state.State
fedDB federatingdb.DB
clock pub.Clock
client pub.HttpClient
@@ -57,14 +57,14 @@ 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 {
+func NewController(state *state.State, federatingDB federatingdb.DB, clock pub.Clock, client pub.HttpClient) Controller {
applicationName := config.GetApplicationName()
host := config.GetHost()
proto := config.GetProtocol()
version := config.GetSoftwareVersion()
c := &controller{
- db: db,
+ state: state,
fedDB: federatingDB,
clock: clock,
client: client,
@@ -138,7 +138,7 @@ func (c *controller) NewTransportForUsername(ctx context.Context, username strin
u = username
}
- ourAccount, err := c.db.GetAccountByUsernameDomain(ctx, u, "")
+ ourAccount, err := c.state.DB.GetAccountByUsernameDomain(ctx, u, "")
if err != nil {
return nil, fmt.Errorf("error getting account %s from db: %s", username, err)
}