diff options
Diffstat (limited to 'internal/typeutils')
-rw-r--r-- | internal/typeutils/converter.go | 2 | ||||
-rw-r--r-- | internal/typeutils/converter_test.go | 7 | ||||
-rw-r--r-- | internal/typeutils/internaltofrontend.go | 8 |
3 files changed, 17 insertions, 0 deletions
diff --git a/internal/typeutils/converter.go b/internal/typeutils/converter.go index 099414a10..00dbe26e8 100644 --- a/internal/typeutils/converter.go +++ b/internal/typeutils/converter.go @@ -92,6 +92,8 @@ type TypeConverter interface { ReportToAPIReport(ctx context.Context, r *gtsmodel.Report) (*apimodel.Report, error) // ReportToAdminAPIReport converts a gts model report into an admin view report, for serving at /api/v1/admin/reports ReportToAdminAPIReport(ctx context.Context, r *gtsmodel.Report, requestingAccount *gtsmodel.Account) (*apimodel.AdminReport, error) + // ListToAPIList converts one gts model list into an api model list, for serving at /api/v1/lists/{id} + ListToAPIList(ctx context.Context, l *gtsmodel.List) (*apimodel.List, error) /* INTERNAL (gts) MODEL TO FRONTEND (rss) MODEL diff --git a/internal/typeutils/converter_test.go b/internal/typeutils/converter_test.go index d92a30c13..a91e6a157 100644 --- a/internal/typeutils/converter_test.go +++ b/internal/typeutils/converter_test.go @@ -25,6 +25,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/processing" "github.com/superseriousbusiness/gotosocial/internal/state" "github.com/superseriousbusiness/gotosocial/internal/typeutils" + "github.com/superseriousbusiness/gotosocial/internal/visibility" "github.com/superseriousbusiness/gotosocial/testrig" ) @@ -515,6 +516,12 @@ func (suite *TypeUtilsTestSuite) TearDownTest() { // Useful when a test in the test suite needs to change some state. func (suite *TypeUtilsTestSuite) GetProcessor() *processing.Processor { testrig.StartWorkers(&suite.state) + testrig.StartTimelines( + &suite.state, + visibility.NewFilter(&suite.state), + testrig.NewTestTypeConverter(suite.db), + ) + httpClient := testrig.NewMockHTTPClient(nil, "../../testrig/media") transportController := testrig.NewTestTransportController(&suite.state, httpClient) mediaManager := testrig.NewTestMediaManager(&suite.state) diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index 53c8af047..7d2056a4c 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -1142,6 +1142,14 @@ func (c *converter) ReportToAdminAPIReport(ctx context.Context, r *gtsmodel.Repo }, nil } +func (c *converter) ListToAPIList(ctx context.Context, l *gtsmodel.List) (*apimodel.List, error) { + return &apimodel.List{ + ID: l.ID, + Title: l.Title, + RepliesPolicy: string(l.RepliesPolicy), + }, nil +} + // convertAttachmentsToAPIAttachments will convert a slice of GTS model attachments to frontend API model attachments, falling back to IDs if no GTS models supplied. func (c *converter) convertAttachmentsToAPIAttachments(ctx context.Context, attachments []*gtsmodel.MediaAttachment, attachmentIDs []string) ([]apimodel.Attachment, error) { var errs gtserror.MultiError |