summaryrefslogtreecommitdiff
path: root/internal/federation/federatingdb
diff options
context:
space:
mode:
Diffstat (limited to 'internal/federation/federatingdb')
-rw-r--r--internal/federation/federatingdb/accept.go2
-rw-r--r--internal/federation/federatingdb/announce.go2
-rw-r--r--internal/federation/federatingdb/create.go10
-rw-r--r--internal/federation/federatingdb/db.go14
-rw-r--r--internal/federation/federatingdb/federatingdb_test.go4
-rw-r--r--internal/federation/federatingdb/get.go4
-rw-r--r--internal/federation/federatingdb/reject.go2
-rw-r--r--internal/federation/federatingdb/undo.go6
8 files changed, 22 insertions, 22 deletions
diff --git a/internal/federation/federatingdb/accept.go b/internal/federation/federatingdb/accept.go
index 27dcec612..1c514d035 100644
--- a/internal/federation/federatingdb/accept.go
+++ b/internal/federation/federatingdb/accept.go
@@ -94,7 +94,7 @@ func (f *federatingDB) Accept(ctx context.Context, accept vocab.ActivityStreamsA
return errors.New("ACCEPT: couldn't parse follow into vocab.ActivityStreamsFollow")
}
// convert the follow to something we can understand
- gtsFollow, err := f.typeConverter.ASFollowToFollow(ctx, asFollow)
+ gtsFollow, err := f.converter.ASFollowToFollow(ctx, asFollow)
if err != nil {
return fmt.Errorf("ACCEPT: error converting asfollow to gtsfollow: %s", err)
}
diff --git a/internal/federation/federatingdb/announce.go b/internal/federation/federatingdb/announce.go
index 334c46ba5..5a5b80bc1 100644
--- a/internal/federation/federatingdb/announce.go
+++ b/internal/federation/federatingdb/announce.go
@@ -44,7 +44,7 @@ func (f *federatingDB) Announce(ctx context.Context, announce vocab.ActivityStre
return nil // Already processed.
}
- boost, isNew, err := f.typeConverter.ASAnnounceToStatus(ctx, announce)
+ boost, isNew, err := f.converter.ASAnnounceToStatus(ctx, announce)
if err != nil {
return gtserror.Newf("error converting announce to boost: %w", err)
}
diff --git a/internal/federation/federatingdb/create.go b/internal/federation/federatingdb/create.go
index 3c9eaf9a5..12e324166 100644
--- a/internal/federation/federatingdb/create.go
+++ b/internal/federation/federatingdb/create.go
@@ -94,7 +94,7 @@ func (f *federatingDB) activityBlock(ctx context.Context, asType vocab.Type, rec
return errors.New("activityBlock: could not convert type to block")
}
- block, err := f.typeConverter.ASBlockToBlock(ctx, blockable)
+ block, err := f.converter.ASBlockToBlock(ctx, blockable)
if err != nil {
return fmt.Errorf("activityBlock: could not convert Block to gts model block")
}
@@ -246,7 +246,7 @@ func (f *federatingDB) createStatusable(
// This is a non-forwarded status we can trust the requester on,
// convert this provided statusable data to a useable gtsmodel status.
- status, err = f.typeConverter.ASStatusToStatus(ctx, statusable)
+ status, err = f.converter.ASStatusToStatus(ctx, statusable)
if err != nil {
return gtserror.Newf("error converting statusable to status: %w", err)
}
@@ -333,7 +333,7 @@ func (f *federatingDB) activityFollow(ctx context.Context, asType vocab.Type, re
return errors.New("activityFollow: could not convert type to follow")
}
- followRequest, err := f.typeConverter.ASFollowToFollowRequest(ctx, follow)
+ followRequest, err := f.converter.ASFollowToFollowRequest(ctx, follow)
if err != nil {
return fmt.Errorf("activityFollow: could not convert Follow to follow request: %s", err)
}
@@ -364,7 +364,7 @@ func (f *federatingDB) activityLike(ctx context.Context, asType vocab.Type, rece
return errors.New("activityLike: could not convert type to like")
}
- fave, err := f.typeConverter.ASLikeToFave(ctx, like)
+ fave, err := f.converter.ASLikeToFave(ctx, like)
if err != nil {
return fmt.Errorf("activityLike: could not convert Like to fave: %w", err)
}
@@ -401,7 +401,7 @@ func (f *federatingDB) activityFlag(ctx context.Context, asType vocab.Type, rece
return errors.New("activityFlag: could not convert type to flag")
}
- report, err := f.typeConverter.ASFlagToReport(ctx, flag)
+ report, err := f.converter.ASFlagToReport(ctx, flag)
if err != nil {
return fmt.Errorf("activityFlag: could not convert Flag to report: %w", err)
}
diff --git a/internal/federation/federatingdb/db.go b/internal/federation/federatingdb/db.go
index bc1415dd5..3f35a96c3 100644
--- a/internal/federation/federatingdb/db.go
+++ b/internal/federation/federatingdb/db.go
@@ -39,17 +39,17 @@ type DB interface {
// FederatingDB uses the underlying DB interface to implement the go-fed pub.Database interface.
// It doesn't care what the underlying implementation of the DB interface is, as long as it works.
type federatingDB struct {
- locks mutexes.MutexMap
- state *state.State
- typeConverter typeutils.TypeConverter
+ locks mutexes.MutexMap
+ state *state.State
+ converter *typeutils.Converter
}
// New returns a DB interface using the given database and config
-func New(state *state.State, tc typeutils.TypeConverter) DB {
+func New(state *state.State, converter *typeutils.Converter) DB {
fdb := federatingDB{
- locks: mutexes.NewMap(-1, -1), // use defaults
- state: state,
- typeConverter: tc,
+ locks: mutexes.NewMap(-1, -1), // use defaults
+ state: state,
+ converter: converter,
}
return &fdb
}
diff --git a/internal/federation/federatingdb/federatingdb_test.go b/internal/federation/federatingdb/federatingdb_test.go
index ea5ebf0c3..5c1428ee1 100644
--- a/internal/federation/federatingdb/federatingdb_test.go
+++ b/internal/federation/federatingdb/federatingdb_test.go
@@ -35,7 +35,7 @@ import (
type FederatingDBTestSuite struct {
suite.Suite
db db.DB
- tc typeutils.TypeConverter
+ tc *typeutils.Converter
fromFederator chan messages.FromFediAPI
federatingDB federatingdb.DB
state state.State
@@ -79,7 +79,7 @@ func (suite *FederatingDBTestSuite) SetupTest() {
suite.db = testrig.NewTestDB(&suite.state)
suite.testActivities = testrig.NewTestActivities(suite.testAccounts)
- suite.tc = testrig.NewTestTypeConverter(suite.db)
+ suite.tc = typeutils.NewConverter(&suite.state)
testrig.StartTimelines(
&suite.state,
diff --git a/internal/federation/federatingdb/get.go b/internal/federation/federatingdb/get.go
index 9ab30db0d..eba58853f 100644
--- a/internal/federation/federatingdb/get.go
+++ b/internal/federation/federatingdb/get.go
@@ -42,13 +42,13 @@ func (f *federatingDB) Get(ctx context.Context, id *url.URL) (value vocab.Type,
if err != nil {
return nil, err
}
- return f.typeConverter.AccountToAS(ctx, acct)
+ return f.converter.AccountToAS(ctx, acct)
case uris.IsStatusesPath(id):
status, err := f.state.DB.GetStatusByURI(ctx, id.String())
if err != nil {
return nil, err
}
- return f.typeConverter.StatusToAS(ctx, status)
+ return f.converter.StatusToAS(ctx, status)
case uris.IsFollowersPath(id):
return f.Followers(ctx, id)
case uris.IsFollowingPath(id):
diff --git a/internal/federation/federatingdb/reject.go b/internal/federation/federatingdb/reject.go
index 10882db83..e02db18e0 100644
--- a/internal/federation/federatingdb/reject.go
+++ b/internal/federation/federatingdb/reject.go
@@ -85,7 +85,7 @@ func (f *federatingDB) Reject(ctx context.Context, reject vocab.ActivityStreamsR
}
// convert the follow to something we can understand
- gtsFollow, err := f.typeConverter.ASFollowToFollow(ctx, asFollow)
+ gtsFollow, err := f.converter.ASFollowToFollow(ctx, asFollow)
if err != nil {
return fmt.Errorf("Reject: error converting asfollow to gtsfollow: %s", err)
}
diff --git a/internal/federation/federatingdb/undo.go b/internal/federation/federatingdb/undo.go
index 704ca5502..84a5bdd47 100644
--- a/internal/federation/federatingdb/undo.go
+++ b/internal/federation/federatingdb/undo.go
@@ -97,7 +97,7 @@ func (f *federatingDB) undoFollow(
return nil
}
- follow, err := f.typeConverter.ASFollowToFollow(ctx, Follow)
+ follow, err := f.converter.ASFollowToFollow(ctx, Follow)
if err != nil {
return fmt.Errorf("undoFollow: error converting ActivityStreams Follow to follow: %w", err)
}
@@ -139,7 +139,7 @@ func (f *federatingDB) undoLike(
return nil
}
- fave, err := f.typeConverter.ASLikeToFave(ctx, Like)
+ fave, err := f.converter.ASLikeToFave(ctx, Like)
if err != nil {
return fmt.Errorf("undoLike: error converting ActivityStreams Like to fave: %w", err)
}
@@ -192,7 +192,7 @@ func (f *federatingDB) undoBlock(
return nil
}
- block, err := f.typeConverter.ASBlockToBlock(ctx, Block)
+ block, err := f.converter.ASBlockToBlock(ctx, Block)
if err != nil {
return fmt.Errorf("undoBlock: error converting ActivityStreams Block to block: %w", err)
}