[feature] add instance-expose-public-timeline flag (#1039)

* Add instance-expose-public-timeline flag

Adds a config flag that allows unauthenticated access to /api/v1/timelines/public. Defaults to false to replicate existing behaviour.

* Update structure following review

* Add comment

* Fix linting
This commit is contained in:
Rob Sargant 2022-11-14 09:30:01 +00:00 committed by GitHub
commit d120743e8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 71 additions and 22 deletions

View file

@ -35,23 +35,19 @@ type TimelineTestSuite struct {
}
func (suite *TimelineTestSuite) TestGetPublicTimeline() {
viewingAccount := suite.testAccounts["local_account_1"]
s, err := suite.db.GetPublicTimeline(context.Background(), viewingAccount.ID, "", "", "", 20, false)
s, err := suite.db.GetPublicTimeline(context.Background(), "", "", "", 20, false)
suite.NoError(err)
suite.Len(s, 6)
}
func (suite *TimelineTestSuite) TestGetPublicTimelineWithFutureStatus() {
viewingAccount := suite.testAccounts["local_account_1"]
futureStatus := getFutureStatus()
if err := suite.db.Put(context.Background(), futureStatus); err != nil {
suite.FailNow(err.Error())
}
s, err := suite.db.GetPublicTimeline(context.Background(), viewingAccount.ID, "", "", "", 20, false)
s, err := suite.db.GetPublicTimeline(context.Background(), "", "", "", 20, false)
suite.NoError(err)
suite.Len(s, 6)