[chore] Use generic pointer function (#2080)

This replaces the different $TypePtr functions with a generic
implementation.
This commit is contained in:
Daenney 2023-08-07 19:38:11 +02:00 committed by GitHub
parent 517829ae6a
commit be3718f6e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 393 additions and 391 deletions

View file

@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/api/auth" "github.com/superseriousbusiness/gotosocial/internal/api/auth"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/testrig" "github.com/superseriousbusiness/gotosocial/internal/util"
) )
type AuthAuthorizeTestSuite struct { type AuthAuthorizeTestSuite struct {
@ -51,8 +51,8 @@ func (suite *AuthAuthorizeTestSuite) TestAccountAuthorizeHandler() {
mutateUserAccount: func(user *gtsmodel.User, account *gtsmodel.Account) []string { mutateUserAccount: func(user *gtsmodel.User, account *gtsmodel.Account) []string {
user.ConfirmedAt = time.Now() user.ConfirmedAt = time.Now()
user.Email = user.UnconfirmedEmail user.Email = user.UnconfirmedEmail
user.Approved = testrig.TrueBool() user.Approved = util.Ptr(true)
user.Disabled = testrig.TrueBool() user.Disabled = util.Ptr(true)
return []string{"confirmed_at", "email", "approved", "disabled"} return []string{"confirmed_at", "email", "approved", "disabled"}
}, },
expectedStatusCode: http.StatusSeeOther, expectedStatusCode: http.StatusSeeOther,
@ -63,8 +63,8 @@ func (suite *AuthAuthorizeTestSuite) TestAccountAuthorizeHandler() {
mutateUserAccount: func(user *gtsmodel.User, account *gtsmodel.Account) []string { mutateUserAccount: func(user *gtsmodel.User, account *gtsmodel.Account) []string {
user.ConfirmedAt = time.Now() user.ConfirmedAt = time.Now()
user.Email = user.UnconfirmedEmail user.Email = user.UnconfirmedEmail
user.Approved = testrig.TrueBool() user.Approved = util.Ptr(true)
user.Disabled = testrig.FalseBool() user.Disabled = util.Ptr(false)
account.SuspendedAt = time.Now() account.SuspendedAt = time.Now()
return []string{"confirmed_at", "email", "approved", "disabled"} return []string{"confirmed_at", "email", "approved", "disabled"}
}, },

View file

@ -138,7 +138,7 @@ func (suite *ReportResolveTestSuite) TestReportResolve2() {
testToken := suite.testTokens["admin_account"] testToken := suite.testTokens["admin_account"]
testUser := suite.testUsers["admin_account"] testUser := suite.testUsers["admin_account"]
testReportID := suite.testReports["local_account_2_report_remote_account_1"].ID testReportID := suite.testReports["local_account_2_report_remote_account_1"].ID
var actionTakenComment *string = testrig.StringPtr("no action was taken, this is a frivolous report you boob") var actionTakenComment *string = util.Ptr("no action was taken, this is a frivolous report you boob")
report, err := suite.resolveReport(testAccount, testToken, testUser, testReportID, http.StatusOK, "", actionTakenComment) report, err := suite.resolveReport(testAccount, testToken, testUser, testReportID, http.StatusOK, "", actionTakenComment)
suite.NoError(err) suite.NoError(err)

View file

@ -32,6 +32,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/gtserror" "github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/oauth" "github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/util"
"github.com/superseriousbusiness/gotosocial/testrig" "github.com/superseriousbusiness/gotosocial/testrig"
) )
@ -963,7 +964,7 @@ func (suite *ReportsGetTestSuite) TestReportsGetResolvedTargetAccount() {
testAccount := suite.testAccounts["admin_account"] testAccount := suite.testAccounts["admin_account"]
testToken := suite.testTokens["admin_account"] testToken := suite.testTokens["admin_account"]
testUser := suite.testUsers["admin_account"] testUser := suite.testUsers["admin_account"]
resolved := testrig.FalseBool() resolved := util.Ptr(false)
targetAccount := suite.testAccounts["local_account_2"] targetAccount := suite.testAccounts["local_account_2"]
reports, link, err := suite.getReports(testAccount, testToken, testUser, http.StatusOK, "", resolved, "", targetAccount.ID, "", "", "", 20) reports, link, err := suite.getReports(testAccount, testToken, testUser, http.StatusOK, "", resolved, "", targetAccount.ID, "", "", "", 20)

View file

@ -32,6 +32,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/api/client/instance" "github.com/superseriousbusiness/gotosocial/internal/api/client/instance"
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/util"
"github.com/superseriousbusiness/gotosocial/testrig" "github.com/superseriousbusiness/gotosocial/testrig"
) )
@ -231,7 +232,7 @@ func (suite *InstancePeersGetTestSuite) TestInstancePeersGetAllWithObfuscated()
Domain: "omg.just.the.worst.org.ever", Domain: "omg.just.the.worst.org.ever",
CreatedByAccountID: "01F8MH17FWEB39HZJ76B6VXSKF", CreatedByAccountID: "01F8MH17FWEB39HZJ76B6VXSKF",
PublicComment: "just absolutely the worst, wowza", PublicComment: "just absolutely the worst, wowza",
Obfuscate: testrig.TrueBool(), Obfuscate: util.Ptr(true),
}) })
suite.NoError(err) suite.NoError(err)

View file

@ -32,6 +32,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/oauth" "github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/util"
"github.com/superseriousbusiness/gotosocial/testrig" "github.com/superseriousbusiness/gotosocial/testrig"
) )
@ -197,7 +198,7 @@ func (suite *ReportsGetTestSuite) TestGetReports4() {
testAccount := suite.testAccounts["local_account_2"] testAccount := suite.testAccounts["local_account_2"]
testToken := suite.testTokens["local_account_2"] testToken := suite.testTokens["local_account_2"]
testUser := suite.testUsers["local_account_2"] testUser := suite.testUsers["local_account_2"]
resolved := testrig.FalseBool() resolved := util.Ptr(false)
reports, link, err := suite.getReports(testAccount, testToken, testUser, http.StatusOK, resolved, "", "", "", "", 20) reports, link, err := suite.getReports(testAccount, testToken, testUser, http.StatusOK, resolved, "", "", "", "", 20)
suite.NoError(err) suite.NoError(err)
@ -252,7 +253,7 @@ func (suite *ReportsGetTestSuite) TestGetReports5() {
testAccount := suite.testAccounts["local_account_1"] testAccount := suite.testAccounts["local_account_1"]
testToken := suite.testTokens["local_account_1"] testToken := suite.testTokens["local_account_1"]
testUser := suite.testUsers["local_account_1"] testUser := suite.testUsers["local_account_1"]
resolved := testrig.TrueBool() resolved := util.Ptr(true)
reports, link, err := suite.getReports(testAccount, testToken, testUser, http.StatusOK, resolved, "", "", "", "", 20) reports, link, err := suite.getReports(testAccount, testToken, testUser, http.StatusOK, resolved, "", "", "", "", 20)
suite.NoError(err) suite.NoError(err)
@ -323,7 +324,7 @@ func (suite *ReportsGetTestSuite) TestGetReports7() {
testAccount := suite.testAccounts["local_account_2"] testAccount := suite.testAccounts["local_account_2"]
testToken := suite.testTokens["local_account_2"] testToken := suite.testTokens["local_account_2"]
testUser := suite.testUsers["local_account_2"] testUser := suite.testUsers["local_account_2"]
resolved := testrig.FalseBool() resolved := util.Ptr(false)
reports, link, err := suite.getReports(testAccount, testToken, testUser, http.StatusOK, resolved, "01F8MH5ZK5VRH73AKHQM6Y9VNX", "", "", "", 20) reports, link, err := suite.getReports(testAccount, testToken, testUser, http.StatusOK, resolved, "01F8MH5ZK5VRH73AKHQM6Y9VNX", "", "", "", 20)
suite.NoError(err) suite.NoError(err)

View file

@ -36,6 +36,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/id" "github.com/superseriousbusiness/gotosocial/internal/id"
"github.com/superseriousbusiness/gotosocial/internal/oauth" "github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/util"
"github.com/superseriousbusiness/gotosocial/testrig" "github.com/superseriousbusiness/gotosocial/testrig"
) )
@ -165,14 +166,14 @@ func (suite *StatusPinTestSuite) TestPinStatusTooManyPins() {
PinnedAt: time.Now(), PinnedAt: time.Now(),
URL: "stub " + strconv.Itoa(i), URL: "stub " + strconv.Itoa(i),
URI: "stub " + strconv.Itoa(i), URI: "stub " + strconv.Itoa(i),
Local: testrig.TrueBool(), Local: util.Ptr(true),
AccountID: testAccount.ID, AccountID: testAccount.ID,
AccountURI: testAccount.URI, AccountURI: testAccount.URI,
Visibility: gtsmodel.VisibilityPublic, Visibility: gtsmodel.VisibilityPublic,
Federated: testrig.TrueBool(), Federated: util.Ptr(true),
Boostable: testrig.TrueBool(), Boostable: util.Ptr(true),
Replyable: testrig.TrueBool(), Replyable: util.Ptr(true),
Likeable: testrig.TrueBool(), Likeable: util.Ptr(true),
ActivityStreamsType: ap.ObjectNote, ActivityStreamsType: ap.ObjectNote,
} }
if err := suite.db.PutStatus(ctx, status); err != nil { if err := suite.db.PutStatus(ctx, status); err != nil {

View file

@ -36,6 +36,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/log" "github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/state" "github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/uris" "github.com/superseriousbusiness/gotosocial/internal/uris"
"github.com/superseriousbusiness/gotosocial/internal/util"
"github.com/uptrace/bun" "github.com/uptrace/bun"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
) )
@ -198,17 +199,15 @@ func (a *adminDB) NewSignup(ctx context.Context, newSignup gtsmodel.NewSignup) (
user.Email = newSignup.Email user.Email = newSignup.Email
} }
trueBool := func() *bool { t := true; return &t }
if newSignup.Admin { if newSignup.Admin {
// Make new user mod + admin. // Make new user mod + admin.
user.Moderator = trueBool() user.Moderator = util.Ptr(true)
user.Admin = trueBool() user.Admin = util.Ptr(true)
} }
if newSignup.PreApproved { if newSignup.PreApproved {
// Mark new user as approved. // Mark new user as approved.
user.Approved = trueBool() user.Approved = util.Ptr(true)
} }
// Insert the user! // Insert the user!

View file

@ -25,7 +25,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/config"
"github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/testrig" "github.com/superseriousbusiness/gotosocial/internal/util"
) )
type InstanceTestSuite struct { type InstanceTestSuite struct {
@ -103,7 +103,7 @@ func (suite *InstanceTestSuite) TestGetInstanceModeratorAddressesZorkAsModerator
// Promote zork to moderator role. // Promote zork to moderator role.
testUser := &gtsmodel.User{} testUser := &gtsmodel.User{}
*testUser = *suite.testUsers["local_account_1"] *testUser = *suite.testUsers["local_account_1"]
testUser.Moderator = testrig.TrueBool() testUser.Moderator = util.Ptr(true)
if err := suite.db.UpdateUser(context.Background(), testUser, "moderator"); err != nil { if err := suite.db.UpdateUser(context.Background(), testUser, "moderator"); err != nil {
suite.FailNow(err.Error()) suite.FailNow(err.Error())
} }
@ -117,8 +117,8 @@ func (suite *InstanceTestSuite) TestGetInstanceModeratorAddressesNoAdmin() {
// Demote admin from admin + moderator roles. // Demote admin from admin + moderator roles.
testUser := &gtsmodel.User{} testUser := &gtsmodel.User{}
*testUser = *suite.testUsers["admin_account"] *testUser = *suite.testUsers["admin_account"]
testUser.Admin = testrig.FalseBool() testUser.Admin = util.Ptr(false)
testUser.Moderator = testrig.FalseBool() testUser.Moderator = util.Ptr(false)
if err := suite.db.UpdateUser(context.Background(), testUser, "admin", "moderator"); err != nil { if err := suite.db.UpdateUser(context.Background(), testUser, "admin", "moderator"); err != nil {
suite.FailNow(err.Error()) suite.FailNow(err.Error())
} }

View file

@ -28,7 +28,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/id" "github.com/superseriousbusiness/gotosocial/internal/id"
"github.com/superseriousbusiness/gotosocial/testrig" "github.com/superseriousbusiness/gotosocial/internal/util"
) )
func (suite *NotificationTestSuite) spamNotifs() { func (suite *NotificationTestSuite) spamNotifs() {
@ -70,7 +70,7 @@ func (suite *NotificationTestSuite) spamNotifs() {
TargetAccountID: targetAccountID, TargetAccountID: targetAccountID,
OriginAccountID: originAccountID, OriginAccountID: originAccountID,
StatusID: statusID, StatusID: statusID,
Read: testrig.FalseBool(), Read: util.Ptr(false),
} }
if err := suite.db.Put(context.Background(), notif); err != nil { if err := suite.db.Put(context.Background(), notif); err != nil {

View file

@ -28,7 +28,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/id" "github.com/superseriousbusiness/gotosocial/internal/id"
"github.com/superseriousbusiness/gotosocial/testrig" "github.com/superseriousbusiness/gotosocial/internal/util"
) )
type RelationshipTestSuite struct { type RelationshipTestSuite struct {
@ -892,7 +892,7 @@ func (suite *RelationshipTestSuite) TestUpdateFollow() {
follow := &gtsmodel.Follow{} follow := &gtsmodel.Follow{}
*follow = *suite.testFollows["local_account_1_admin_account"] *follow = *suite.testFollows["local_account_1_admin_account"]
follow.Notify = testrig.TrueBool() follow.Notify = util.Ptr(true)
if err := suite.db.UpdateFollow(ctx, follow, "notify"); err != nil { if err := suite.db.UpdateFollow(ctx, follow, "notify"); err != nil {
suite.FailNow(err.Error()) suite.FailNow(err.Error())
} }

View file

@ -24,6 +24,7 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/util"
"github.com/superseriousbusiness/gotosocial/testrig" "github.com/superseriousbusiness/gotosocial/testrig"
) )
@ -88,7 +89,7 @@ func (suite *ReportTestSuite) TestPutReport() {
TargetAccountID: "01F8MH5ZK5VRH73AKHQM6Y9VNX", TargetAccountID: "01F8MH5ZK5VRH73AKHQM6Y9VNX",
Comment: "another report", Comment: "another report",
StatusIDs: []string{"01FVW7JHQFSFK166WWKR8CBA6M"}, StatusIDs: []string{"01FVW7JHQFSFK166WWKR8CBA6M"},
Forwarded: testrig.TrueBool(), Forwarded: util.Ptr(true),
} }
err := suite.db.PutReport(ctx, report) err := suite.db.PutReport(ctx, report)

View file

@ -26,7 +26,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/ap" "github.com/superseriousbusiness/gotosocial/internal/ap"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/id" "github.com/superseriousbusiness/gotosocial/internal/id"
"github.com/superseriousbusiness/gotosocial/testrig" "github.com/superseriousbusiness/gotosocial/internal/util"
) )
type TimelineTestSuite struct { type TimelineTestSuite struct {
@ -52,20 +52,20 @@ func getFutureStatus() *gtsmodel.Status {
EmojiIDs: []string{}, EmojiIDs: []string{},
CreatedAt: theDistantFuture, CreatedAt: theDistantFuture,
UpdatedAt: theDistantFuture, UpdatedAt: theDistantFuture,
Local: testrig.TrueBool(), Local: util.Ptr(true),
AccountURI: "http://localhost:8080/users/admin", AccountURI: "http://localhost:8080/users/admin",
AccountID: "01F8MH17FWEB39HZJ76B6VXSKF", AccountID: "01F8MH17FWEB39HZJ76B6VXSKF",
InReplyToID: "", InReplyToID: "",
BoostOfID: "", BoostOfID: "",
ContentWarning: "", ContentWarning: "",
Visibility: gtsmodel.VisibilityPublic, Visibility: gtsmodel.VisibilityPublic,
Sensitive: testrig.FalseBool(), Sensitive: util.Ptr(false),
Language: "en", Language: "en",
CreatedWithApplicationID: "01F8MGXQRHYF5QPMTMXP78QC2F", CreatedWithApplicationID: "01F8MGXQRHYF5QPMTMXP78QC2F",
Federated: testrig.TrueBool(), Federated: util.Ptr(true),
Boostable: testrig.TrueBool(), Boostable: util.Ptr(true),
Replyable: testrig.TrueBool(), Replyable: util.Ptr(true),
Likeable: testrig.TrueBool(), Likeable: util.Ptr(true),
ActivityStreamsType: ap.ObjectNote, ActivityStreamsType: ap.ObjectNote,
} }
} }

View file

@ -28,6 +28,7 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/federation" "github.com/superseriousbusiness/gotosocial/internal/federation"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/util"
"github.com/superseriousbusiness/gotosocial/testrig" "github.com/superseriousbusiness/gotosocial/testrig"
) )
@ -80,9 +81,9 @@ func (suite *FederatingActorTestSuite) TestSendRemoteFollower() {
UpdatedAt: testrig.TimeMustParse("2022-06-02T12:22:21+02:00"), UpdatedAt: testrig.TimeMustParse("2022-06-02T12:22:21+02:00"),
AccountID: testRemoteAccount.ID, AccountID: testRemoteAccount.ID,
TargetAccountID: testAccount.ID, TargetAccountID: testAccount.ID,
ShowReblogs: testrig.TrueBool(), ShowReblogs: util.Ptr(true),
URI: "http://fossbros-anonymous.io/users/foss_satan/follows/01G1TRWV4AYCDBX5HRWT2EVBCV", URI: "http://fossbros-anonymous.io/users/foss_satan/follows/01G1TRWV4AYCDBX5HRWT2EVBCV",
Notify: testrig.FalseBool(), Notify: util.Ptr(false),
}) })
suite.NoError(err) suite.NoError(err)

View file

@ -31,6 +31,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/log" "github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/messages" "github.com/superseriousbusiness/gotosocial/internal/messages"
"github.com/superseriousbusiness/gotosocial/internal/util"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
) )
@ -427,8 +428,6 @@ func (p *Processor) deleteAccountPeripheral(ctx context.Context, account *gtsmod
// names of all columns that are updated by it. // names of all columns that are updated by it.
func stubbifyAccount(account *gtsmodel.Account, origin string) []string { func stubbifyAccount(account *gtsmodel.Account, origin string) []string {
var ( var (
falseBool = func() *bool { b := false; return &b }
trueBool = func() *bool { b := true; return &b }
now = time.Now() now = time.Now()
never = time.Time{} never = time.Time{}
) )
@ -444,17 +443,17 @@ func stubbifyAccount(account *gtsmodel.Account, origin string) []string {
account.Fields = nil account.Fields = nil
account.Note = "" account.Note = ""
account.NoteRaw = "" account.NoteRaw = ""
account.Memorial = falseBool() account.Memorial = util.Ptr(false)
account.AlsoKnownAs = "" account.AlsoKnownAs = ""
account.MovedToAccountID = "" account.MovedToAccountID = ""
account.Reason = "" account.Reason = ""
account.Discoverable = falseBool() account.Discoverable = util.Ptr(false)
account.StatusContentType = "" account.StatusContentType = ""
account.CustomCSS = "" account.CustomCSS = ""
account.SuspendedAt = now account.SuspendedAt = now
account.SuspensionOrigin = origin account.SuspensionOrigin = origin
account.HideCollections = trueBool() account.HideCollections = util.Ptr(true)
account.EnableRSS = falseBool() account.EnableRSS = util.Ptr(false)
return []string{ return []string{
"fetched_at", "fetched_at",

View file

@ -23,7 +23,7 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/testrig" "github.com/superseriousbusiness/gotosocial/internal/util"
) )
type FollowTestSuite struct { type FollowTestSuite struct {
@ -40,10 +40,9 @@ func (suite *FollowTestSuite) TestUpdateExistingFollowChangeBoth() {
// UPDATE "follows" AS "follow" SET "show_reblogs" = FALSE, "notify" = TRUE, "updated_at" = '2023-04-09 11:42:39.424705+00:00' WHERE ("follow"."id" = '01F8PY8RHWRQZV038T4E8T9YK8') // UPDATE "follows" AS "follow" SET "show_reblogs" = FALSE, "notify" = TRUE, "updated_at" = '2023-04-09 11:42:39.424705+00:00' WHERE ("follow"."id" = '01F8PY8RHWRQZV038T4E8T9YK8')
relationship, err := suite.accountProcessor.FollowCreate(ctx, requestingAccount, &apimodel.AccountFollowRequest{ relationship, err := suite.accountProcessor.FollowCreate(ctx, requestingAccount, &apimodel.AccountFollowRequest{
ID: targetAccount.ID, ID: targetAccount.ID,
Reblogs: testrig.FalseBool(), Reblogs: util.Ptr(false),
Notify: testrig.TrueBool(), Notify: util.Ptr(true),
}) })
if err != nil { if err != nil {
suite.FailNow(err.Error()) suite.FailNow(err.Error())
} }
@ -62,9 +61,8 @@ func (suite *FollowTestSuite) TestUpdateExistingFollowChangeNotifyIgnoreReblogs(
// UPDATE "follows" AS "follow" SET "notify" = TRUE, "updated_at" = '2023-04-09 11:40:33.827858+00:00' WHERE ("follow"."id" = '01F8PY8RHWRQZV038T4E8T9YK8') // UPDATE "follows" AS "follow" SET "notify" = TRUE, "updated_at" = '2023-04-09 11:40:33.827858+00:00' WHERE ("follow"."id" = '01F8PY8RHWRQZV038T4E8T9YK8')
relationship, err := suite.accountProcessor.FollowCreate(ctx, requestingAccount, &apimodel.AccountFollowRequest{ relationship, err := suite.accountProcessor.FollowCreate(ctx, requestingAccount, &apimodel.AccountFollowRequest{
ID: targetAccount.ID, ID: targetAccount.ID,
Notify: testrig.TrueBool(), Notify: util.Ptr(true),
}) })
if err != nil { if err != nil {
suite.FailNow(err.Error()) suite.FailNow(err.Error())
} }
@ -83,10 +81,9 @@ func (suite *FollowTestSuite) TestUpdateExistingFollowChangeNotifySetReblogs() {
// UPDATE "follows" AS "follow" SET "notify" = TRUE, "updated_at" = '2023-04-09 11:40:33.827858+00:00' WHERE ("follow"."id" = '01F8PY8RHWRQZV038T4E8T9YK8') // UPDATE "follows" AS "follow" SET "notify" = TRUE, "updated_at" = '2023-04-09 11:40:33.827858+00:00' WHERE ("follow"."id" = '01F8PY8RHWRQZV038T4E8T9YK8')
relationship, err := suite.accountProcessor.FollowCreate(ctx, requestingAccount, &apimodel.AccountFollowRequest{ relationship, err := suite.accountProcessor.FollowCreate(ctx, requestingAccount, &apimodel.AccountFollowRequest{
ID: targetAccount.ID, ID: targetAccount.ID,
Notify: testrig.TrueBool(), Notify: util.Ptr(true),
Reblogs: testrig.TrueBool(), Reblogs: util.Ptr(true),
}) })
if err != nil { if err != nil {
suite.FailNow(err.Error()) suite.FailNow(err.Error())
} }
@ -104,10 +101,9 @@ func (suite *FollowTestSuite) TestUpdateExistingFollowChangeNothing() {
// Trace logs should show no update query. // Trace logs should show no update query.
relationship, err := suite.accountProcessor.FollowCreate(ctx, requestingAccount, &apimodel.AccountFollowRequest{ relationship, err := suite.accountProcessor.FollowCreate(ctx, requestingAccount, &apimodel.AccountFollowRequest{
ID: targetAccount.ID, ID: targetAccount.ID,
Notify: testrig.FalseBool(), Notify: util.Ptr(false),
Reblogs: testrig.TrueBool(), Reblogs: util.Ptr(true),
}) })
if err != nil { if err != nil {
suite.FailNow(err.Error()) suite.FailNow(err.Error())
} }
@ -126,7 +122,6 @@ func (suite *FollowTestSuite) TestUpdateExistingFollowSetNothing() {
relationship, err := suite.accountProcessor.FollowCreate(ctx, requestingAccount, &apimodel.AccountFollowRequest{ relationship, err := suite.accountProcessor.FollowCreate(ctx, requestingAccount, &apimodel.AccountFollowRequest{
ID: targetAccount.ID, ID: targetAccount.ID,
}) })
if err != nil { if err != nil {
suite.FailNow(err.Error()) suite.FailNow(err.Error())
} }

View file

@ -30,6 +30,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/messages" "github.com/superseriousbusiness/gotosocial/internal/messages"
"github.com/superseriousbusiness/gotosocial/internal/stream" "github.com/superseriousbusiness/gotosocial/internal/stream"
"github.com/superseriousbusiness/gotosocial/internal/util"
"github.com/superseriousbusiness/gotosocial/testrig" "github.com/superseriousbusiness/gotosocial/testrig"
) )
@ -63,20 +64,20 @@ func (suite *FromClientAPITestSuite) TestProcessStreamNewStatus() {
EmojiIDs: []string{}, EmojiIDs: []string{},
CreatedAt: testrig.TimeMustParse("2021-10-20T11:36:45Z"), CreatedAt: testrig.TimeMustParse("2021-10-20T11:36:45Z"),
UpdatedAt: testrig.TimeMustParse("2021-10-20T11:36:45Z"), UpdatedAt: testrig.TimeMustParse("2021-10-20T11:36:45Z"),
Local: testrig.TrueBool(), Local: util.Ptr(true),
AccountURI: "http://localhost:8080/users/admin", AccountURI: "http://localhost:8080/users/admin",
AccountID: "01F8MH17FWEB39HZJ76B6VXSKF", AccountID: "01F8MH17FWEB39HZJ76B6VXSKF",
InReplyToID: "", InReplyToID: "",
BoostOfID: "", BoostOfID: "",
ContentWarning: "", ContentWarning: "",
Visibility: gtsmodel.VisibilityFollowersOnly, Visibility: gtsmodel.VisibilityFollowersOnly,
Sensitive: testrig.FalseBool(), Sensitive: util.Ptr(false),
Language: "en", Language: "en",
CreatedWithApplicationID: "01F8MGXQRHYF5QPMTMXP78QC2F", CreatedWithApplicationID: "01F8MGXQRHYF5QPMTMXP78QC2F",
Federated: testrig.FalseBool(), Federated: util.Ptr(false),
Boostable: testrig.TrueBool(), Boostable: util.Ptr(true),
Replyable: testrig.TrueBool(), Replyable: util.Ptr(true),
Likeable: testrig.TrueBool(), Likeable: util.Ptr(true),
ActivityStreamsType: ap.ObjectNote, ActivityStreamsType: ap.ObjectNote,
} }
@ -189,7 +190,7 @@ func (suite *FromClientAPITestSuite) TestProcessNewStatusWithNotification() {
// that receiving account wants notifs when posting account posts. // that receiving account wants notifs when posting account posts.
follow := &gtsmodel.Follow{} follow := &gtsmodel.Follow{}
*follow = *suite.testFollows["local_account_1_admin_account"] *follow = *suite.testFollows["local_account_1_admin_account"]
follow.Notify = testrig.TrueBool() follow.Notify = util.Ptr(true)
if err := suite.db.UpdateFollow(ctx, follow); err != nil { if err := suite.db.UpdateFollow(ctx, follow); err != nil {
suite.FailNow(err.Error()) suite.FailNow(err.Error())
} }
@ -206,20 +207,20 @@ func (suite *FromClientAPITestSuite) TestProcessNewStatusWithNotification() {
EmojiIDs: []string{}, EmojiIDs: []string{},
CreatedAt: testrig.TimeMustParse("2021-10-20T11:36:45Z"), CreatedAt: testrig.TimeMustParse("2021-10-20T11:36:45Z"),
UpdatedAt: testrig.TimeMustParse("2021-10-20T11:36:45Z"), UpdatedAt: testrig.TimeMustParse("2021-10-20T11:36:45Z"),
Local: testrig.TrueBool(), Local: util.Ptr(true),
AccountURI: "http://localhost:8080/users/admin", AccountURI: "http://localhost:8080/users/admin",
AccountID: "01F8MH17FWEB39HZJ76B6VXSKF", AccountID: "01F8MH17FWEB39HZJ76B6VXSKF",
InReplyToID: "", InReplyToID: "",
BoostOfID: "", BoostOfID: "",
ContentWarning: "", ContentWarning: "",
Visibility: gtsmodel.VisibilityFollowersOnly, Visibility: gtsmodel.VisibilityFollowersOnly,
Sensitive: testrig.FalseBool(), Sensitive: util.Ptr(false),
Language: "en", Language: "en",
CreatedWithApplicationID: "01F8MGXQRHYF5QPMTMXP78QC2F", CreatedWithApplicationID: "01F8MGXQRHYF5QPMTMXP78QC2F",
Federated: testrig.FalseBool(), Federated: util.Ptr(false),
Boostable: testrig.TrueBool(), Boostable: util.Ptr(true),
Replyable: testrig.TrueBool(), Replyable: util.Ptr(true),
Likeable: testrig.TrueBool(), Likeable: util.Ptr(true),
ActivityStreamsType: ap.ObjectNote, ActivityStreamsType: ap.ObjectNote,
} }

View file

@ -32,6 +32,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/id" "github.com/superseriousbusiness/gotosocial/internal/id"
"github.com/superseriousbusiness/gotosocial/internal/messages" "github.com/superseriousbusiness/gotosocial/internal/messages"
"github.com/superseriousbusiness/gotosocial/internal/stream" "github.com/superseriousbusiness/gotosocial/internal/stream"
"github.com/superseriousbusiness/gotosocial/internal/util"
"github.com/superseriousbusiness/gotosocial/testrig" "github.com/superseriousbusiness/gotosocial/testrig"
) )
@ -110,10 +111,10 @@ func (suite *FromFederatorTestSuite) TestProcessReplyMention() {
InReplyToAccountID: repliedAccount.ID, InReplyToAccountID: repliedAccount.ID,
Visibility: gtsmodel.VisibilityUnlocked, Visibility: gtsmodel.VisibilityUnlocked,
ActivityStreamsType: ap.ObjectNote, ActivityStreamsType: ap.ObjectNote,
Federated: testrig.TrueBool(), Federated: util.Ptr(true),
Boostable: testrig.TrueBool(), Boostable: util.Ptr(true),
Replyable: testrig.TrueBool(), Replyable: util.Ptr(true),
Likeable: testrig.FalseBool(), Likeable: util.Ptr(false),
} }
wssStream, errWithCode := suite.processor.Stream().Open(context.Background(), repliedAccount, stream.TimelineHome) wssStream, errWithCode := suite.processor.Stream().Open(context.Background(), repliedAccount, stream.TimelineHome)
@ -317,9 +318,9 @@ func (suite *FromFederatorTestSuite) TestProcessAccountDelete() {
UpdatedAt: time.Now().Add(-1 * time.Hour), UpdatedAt: time.Now().Add(-1 * time.Hour),
AccountID: deletedAccount.ID, AccountID: deletedAccount.ID,
TargetAccountID: receivingAccount.ID, TargetAccountID: receivingAccount.ID,
ShowReblogs: testrig.TrueBool(), ShowReblogs: util.Ptr(true),
URI: fmt.Sprintf("%s/follows/01FGRY72ASHBSET64353DPHK9T", deletedAccount.URI), URI: fmt.Sprintf("%s/follows/01FGRY72ASHBSET64353DPHK9T", deletedAccount.URI),
Notify: testrig.FalseBool(), Notify: util.Ptr(false),
} }
err := suite.db.Put(ctx, zorkFollowSatan) err := suite.db.Put(ctx, zorkFollowSatan)
suite.NoError(err) suite.NoError(err)
@ -330,9 +331,9 @@ func (suite *FromFederatorTestSuite) TestProcessAccountDelete() {
UpdatedAt: time.Now().Add(-1 * time.Hour), UpdatedAt: time.Now().Add(-1 * time.Hour),
AccountID: receivingAccount.ID, AccountID: receivingAccount.ID,
TargetAccountID: deletedAccount.ID, TargetAccountID: deletedAccount.ID,
ShowReblogs: testrig.TrueBool(), ShowReblogs: util.Ptr(true),
URI: fmt.Sprintf("%s/follows/01FGRYAVAWWPP926J175QGM0WV", receivingAccount.URI), URI: fmt.Sprintf("%s/follows/01FGRYAVAWWPP926J175QGM0WV", receivingAccount.URI),
Notify: testrig.FalseBool(), Notify: util.Ptr(false),
} }
err = suite.db.Put(ctx, satanFollowZork) err = suite.db.Put(ctx, satanFollowZork)
suite.NoError(err) suite.NoError(err)
@ -405,9 +406,9 @@ func (suite *FromFederatorTestSuite) TestProcessFollowRequestLocked() {
Account: originAccount, Account: originAccount,
TargetAccountID: targetAccount.ID, TargetAccountID: targetAccount.ID,
TargetAccount: targetAccount, TargetAccount: targetAccount,
ShowReblogs: testrig.TrueBool(), ShowReblogs: util.Ptr(true),
URI: fmt.Sprintf("%s/follows/01FGRYAVAWWPP926J175QGM0WV", originAccount.URI), URI: fmt.Sprintf("%s/follows/01FGRYAVAWWPP926J175QGM0WV", originAccount.URI),
Notify: testrig.FalseBool(), Notify: util.Ptr(false),
} }
err := suite.db.Put(ctx, satanFollowRequestTurtle) err := suite.db.Put(ctx, satanFollowRequestTurtle)
@ -462,9 +463,9 @@ func (suite *FromFederatorTestSuite) TestProcessFollowRequestUnlocked() {
Account: originAccount, Account: originAccount,
TargetAccountID: targetAccount.ID, TargetAccountID: targetAccount.ID,
TargetAccount: targetAccount, TargetAccount: targetAccount,
ShowReblogs: testrig.TrueBool(), ShowReblogs: util.Ptr(true),
URI: fmt.Sprintf("%s/follows/01FGRYAVAWWPP926J175QGM0WV", originAccount.URI), URI: fmt.Sprintf("%s/follows/01FGRYAVAWWPP926J175QGM0WV", originAccount.URI),
Notify: testrig.FalseBool(), Notify: util.Ptr(false),
} }
err := suite.db.Put(ctx, satanFollowRequestTurtle) err := suite.db.Put(ctx, satanFollowRequestTurtle)

View file

@ -28,6 +28,7 @@ import (
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model" apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/media" "github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/util"
"github.com/superseriousbusiness/gotosocial/testrig" "github.com/superseriousbusiness/gotosocial/testrig"
) )
@ -68,7 +69,7 @@ func (suite *GetFileTestSuite) TestGetRemoteFileUncached() {
// uncache the file from local // uncache the file from local
testAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"] testAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
testAttachment.Cached = testrig.FalseBool() testAttachment.Cached = util.Ptr(false)
err := suite.db.UpdateByID(ctx, testAttachment, testAttachment.ID, "cached") err := suite.db.UpdateByID(ctx, testAttachment, testAttachment.ID, "cached")
suite.NoError(err) suite.NoError(err)
err = suite.storage.Delete(ctx, testAttachment.File.Path) err = suite.storage.Delete(ctx, testAttachment.File.Path)
@ -120,7 +121,7 @@ func (suite *GetFileTestSuite) TestGetRemoteFileUncachedInterrupted() {
// uncache the file from local // uncache the file from local
testAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"] testAttachment := suite.testAttachments["remote_account_1_status_1_attachment_1"]
testAttachment.Cached = testrig.FalseBool() testAttachment.Cached = util.Ptr(false)
err := suite.db.UpdateByID(ctx, testAttachment, testAttachment.ID, "cached") err := suite.db.UpdateByID(ctx, testAttachment, testAttachment.ID, "cached")
suite.NoError(err) suite.NoError(err)
err = suite.storage.Delete(ctx, testAttachment.File.Path) err = suite.storage.Delete(ctx, testAttachment.File.Path)
@ -177,7 +178,7 @@ func (suite *GetFileTestSuite) TestGetRemoteFileThumbnailUncached() {
suite.NoError(err) suite.NoError(err)
// uncache the file from local // uncache the file from local
testAttachment.Cached = testrig.FalseBool() testAttachment.Cached = util.Ptr(false)
err = suite.db.UpdateByID(ctx, testAttachment, testAttachment.ID, "cached") err = suite.db.UpdateByID(ctx, testAttachment, testAttachment.ID, "cached")
suite.NoError(err) suite.NoError(err)
err = suite.storage.Delete(ctx, testAttachment.File.Path) err = suite.storage.Delete(ctx, testAttachment.File.Path)

View file

@ -31,6 +31,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/log" "github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/uris" "github.com/superseriousbusiness/gotosocial/internal/uris"
"github.com/superseriousbusiness/gotosocial/internal/util"
) )
func (c *converter) ASRepresentationToAccount(ctx context.Context, accountable ap.Accountable, accountDomain string) (*gtsmodel.Account, error) { func (c *converter) ASRepresentationToAccount(ctx context.Context, accountable ap.Accountable, accountDomain string) (*gtsmodel.Account, error) {
@ -396,11 +397,10 @@ func (c *converter) ASStatusToStatus(ctx context.Context, statusable ap.Statusab
// TODO: a lot of work to be done here -- a new type // TODO: a lot of work to be done here -- a new type
// needs to be created for this in go-fed/activity. // needs to be created for this in go-fed/activity.
// Until this is implemented, assume all true. // Until this is implemented, assume all true.
var trueBool = func() *bool { b := true; return &b } status.Federated = util.Ptr(true)
status.Federated = trueBool() status.Boostable = util.Ptr(true)
status.Boostable = trueBool() status.Replyable = util.Ptr(true)
status.Replyable = trueBool() status.Likeable = util.Ptr(true)
status.Likeable = trueBool()
// status.Sensitive // status.Sensitive
status.Sensitive = func() *bool { status.Sensitive = func() *bool {

23
internal/util/ptr.go Normal file
View file

@ -0,0 +1,23 @@
// GoToSocial
// Copyright (C) GoToSocial Authors admin@gotosocial.org
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package util
// Ptr returns a pointer to the passed in type
func Ptr[T any](t T) *T {
return &t
}

View file

@ -25,6 +25,7 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
"github.com/superseriousbusiness/gotosocial/internal/ap" "github.com/superseriousbusiness/gotosocial/internal/ap"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/util"
"github.com/superseriousbusiness/gotosocial/testrig" "github.com/superseriousbusiness/gotosocial/testrig"
) )
@ -115,7 +116,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestThread() {
Content: "nbnbdy expects dog", Content: "nbnbdy expects dog",
CreatedAt: testrig.TimeMustParse("2021-09-20T12:41:37+02:00"), CreatedAt: testrig.TimeMustParse("2021-09-20T12:41:37+02:00"),
UpdatedAt: testrig.TimeMustParse("2021-09-20T12:41:37+02:00"), UpdatedAt: testrig.TimeMustParse("2021-09-20T12:41:37+02:00"),
Local: testrig.FalseBool(), Local: util.Ptr(false),
AccountURI: "http://localhost:8080/users/the_mighty_zork", AccountURI: "http://localhost:8080/users/the_mighty_zork",
AccountID: threadParentAccount.ID, AccountID: threadParentAccount.ID,
InReplyToID: originalStatus.ID, InReplyToID: originalStatus.ID,
@ -124,13 +125,13 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestThread() {
BoostOfID: "", BoostOfID: "",
ContentWarning: "", ContentWarning: "",
Visibility: gtsmodel.VisibilityFollowersOnly, Visibility: gtsmodel.VisibilityFollowersOnly,
Sensitive: testrig.FalseBool(), Sensitive: util.Ptr(false),
Language: "en", Language: "en",
CreatedWithApplicationID: "", CreatedWithApplicationID: "",
Federated: testrig.TrueBool(), Federated: util.Ptr(true),
Boostable: testrig.TrueBool(), Boostable: util.Ptr(true),
Replyable: testrig.TrueBool(), Replyable: util.Ptr(true),
Likeable: testrig.TrueBool(), Likeable: util.Ptr(true),
ActivityStreamsType: ap.ObjectNote, ActivityStreamsType: ap.ObjectNote,
} }
if err := suite.db.PutStatus(ctx, firstReplyStatus); err != nil { if err := suite.db.PutStatus(ctx, firstReplyStatus); err != nil {
@ -168,7 +169,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestChainReplyFollowersOnly(
Content: "didn't expect dog", Content: "didn't expect dog",
CreatedAt: testrig.TimeMustParse("2021-09-20T12:40:37+02:00"), CreatedAt: testrig.TimeMustParse("2021-09-20T12:40:37+02:00"),
UpdatedAt: testrig.TimeMustParse("2021-09-20T12:40:37+02:00"), UpdatedAt: testrig.TimeMustParse("2021-09-20T12:40:37+02:00"),
Local: testrig.FalseBool(), Local: util.Ptr(false),
AccountURI: "http://fossbros-anonymous.io/users/foss_satan", AccountURI: "http://fossbros-anonymous.io/users/foss_satan",
AccountID: originalStatusParent.ID, AccountID: originalStatusParent.ID,
InReplyToID: "", InReplyToID: "",
@ -177,13 +178,13 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestChainReplyFollowersOnly(
BoostOfID: "", BoostOfID: "",
ContentWarning: "", ContentWarning: "",
Visibility: gtsmodel.VisibilityFollowersOnly, Visibility: gtsmodel.VisibilityFollowersOnly,
Sensitive: testrig.FalseBool(), Sensitive: util.Ptr(false),
Language: "en", Language: "en",
CreatedWithApplicationID: "", CreatedWithApplicationID: "",
Federated: testrig.TrueBool(), Federated: util.Ptr(true),
Boostable: testrig.TrueBool(), Boostable: util.Ptr(true),
Replyable: testrig.TrueBool(), Replyable: util.Ptr(true),
Likeable: testrig.TrueBool(), Likeable: util.Ptr(true),
ActivityStreamsType: ap.ObjectNote, ActivityStreamsType: ap.ObjectNote,
} }
if err := suite.db.PutStatus(ctx, originalStatus); err != nil { if err := suite.db.PutStatus(ctx, originalStatus); err != nil {
@ -202,7 +203,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestChainReplyFollowersOnly(
Content: "nbnbdy expects dog", Content: "nbnbdy expects dog",
CreatedAt: testrig.TimeMustParse("2021-09-20T12:41:37+02:00"), CreatedAt: testrig.TimeMustParse("2021-09-20T12:41:37+02:00"),
UpdatedAt: testrig.TimeMustParse("2021-09-20T12:41:37+02:00"), UpdatedAt: testrig.TimeMustParse("2021-09-20T12:41:37+02:00"),
Local: testrig.FalseBool(), Local: util.Ptr(false),
AccountURI: "http://localhost:8080/users/the_mighty_zork", AccountURI: "http://localhost:8080/users/the_mighty_zork",
AccountID: replyingAccount.ID, AccountID: replyingAccount.ID,
InReplyToID: originalStatus.ID, InReplyToID: originalStatus.ID,
@ -211,13 +212,13 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestChainReplyFollowersOnly(
BoostOfID: "", BoostOfID: "",
ContentWarning: "", ContentWarning: "",
Visibility: gtsmodel.VisibilityFollowersOnly, Visibility: gtsmodel.VisibilityFollowersOnly,
Sensitive: testrig.FalseBool(), Sensitive: util.Ptr(false),
Language: "en", Language: "en",
CreatedWithApplicationID: "", CreatedWithApplicationID: "",
Federated: testrig.TrueBool(), Federated: util.Ptr(true),
Boostable: testrig.TrueBool(), Boostable: util.Ptr(true),
Replyable: testrig.TrueBool(), Replyable: util.Ptr(true),
Likeable: testrig.TrueBool(), Likeable: util.Ptr(true),
ActivityStreamsType: ap.ObjectNote, ActivityStreamsType: ap.ObjectNote,
} }
if err := suite.db.PutStatus(ctx, firstReplyStatus); err != nil { if err := suite.db.PutStatus(ctx, firstReplyStatus); err != nil {
@ -236,7 +237,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestChainReplyFollowersOnly(
Content: "*nobody", Content: "*nobody",
CreatedAt: testrig.TimeMustParse("2021-09-20T12:42:37+02:00"), CreatedAt: testrig.TimeMustParse("2021-09-20T12:42:37+02:00"),
UpdatedAt: testrig.TimeMustParse("2021-09-20T12:42:37+02:00"), UpdatedAt: testrig.TimeMustParse("2021-09-20T12:42:37+02:00"),
Local: testrig.FalseBool(), Local: util.Ptr(false),
AccountURI: "http://localhost:8080/users/the_mighty_zork", AccountURI: "http://localhost:8080/users/the_mighty_zork",
AccountID: replyingAccount.ID, AccountID: replyingAccount.ID,
InReplyToID: firstReplyStatus.ID, InReplyToID: firstReplyStatus.ID,
@ -245,13 +246,13 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestChainReplyFollowersOnly(
BoostOfID: "", BoostOfID: "",
ContentWarning: "", ContentWarning: "",
Visibility: gtsmodel.VisibilityFollowersOnly, Visibility: gtsmodel.VisibilityFollowersOnly,
Sensitive: testrig.FalseBool(), Sensitive: util.Ptr(false),
Language: "en", Language: "en",
CreatedWithApplicationID: "", CreatedWithApplicationID: "",
Federated: testrig.TrueBool(), Federated: util.Ptr(true),
Boostable: testrig.TrueBool(), Boostable: util.Ptr(true),
Replyable: testrig.TrueBool(), Replyable: util.Ptr(true),
Likeable: testrig.TrueBool(), Likeable: util.Ptr(true),
ActivityStreamsType: ap.ObjectNote, ActivityStreamsType: ap.ObjectNote,
} }
if err := suite.db.PutStatus(ctx, secondReplyStatus); err != nil { if err := suite.db.PutStatus(ctx, secondReplyStatus); err != nil {
@ -281,7 +282,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestChainReplyPublicAndUnloc
Content: "didn't expect dog", Content: "didn't expect dog",
CreatedAt: testrig.TimeMustParse("2021-09-20T12:40:37+02:00"), CreatedAt: testrig.TimeMustParse("2021-09-20T12:40:37+02:00"),
UpdatedAt: testrig.TimeMustParse("2021-09-20T12:40:37+02:00"), UpdatedAt: testrig.TimeMustParse("2021-09-20T12:40:37+02:00"),
Local: testrig.FalseBool(), Local: util.Ptr(false),
AccountURI: "http://fossbros-anonymous.io/users/foss_satan", AccountURI: "http://fossbros-anonymous.io/users/foss_satan",
AccountID: originalStatusParent.ID, AccountID: originalStatusParent.ID,
InReplyToID: "", InReplyToID: "",
@ -290,13 +291,13 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestChainReplyPublicAndUnloc
BoostOfID: "", BoostOfID: "",
ContentWarning: "", ContentWarning: "",
Visibility: gtsmodel.VisibilityUnlocked, Visibility: gtsmodel.VisibilityUnlocked,
Sensitive: testrig.FalseBool(), Sensitive: util.Ptr(false),
Language: "en", Language: "en",
CreatedWithApplicationID: "", CreatedWithApplicationID: "",
Federated: testrig.TrueBool(), Federated: util.Ptr(true),
Boostable: testrig.TrueBool(), Boostable: util.Ptr(true),
Replyable: testrig.TrueBool(), Replyable: util.Ptr(true),
Likeable: testrig.TrueBool(), Likeable: util.Ptr(true),
ActivityStreamsType: ap.ObjectNote, ActivityStreamsType: ap.ObjectNote,
} }
if err := suite.db.PutStatus(ctx, originalStatus); err != nil { if err := suite.db.PutStatus(ctx, originalStatus); err != nil {
@ -315,7 +316,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestChainReplyPublicAndUnloc
Content: "nbnbdy expects dog", Content: "nbnbdy expects dog",
CreatedAt: testrig.TimeMustParse("2021-09-20T12:41:37+02:00"), CreatedAt: testrig.TimeMustParse("2021-09-20T12:41:37+02:00"),
UpdatedAt: testrig.TimeMustParse("2021-09-20T12:41:37+02:00"), UpdatedAt: testrig.TimeMustParse("2021-09-20T12:41:37+02:00"),
Local: testrig.FalseBool(), Local: util.Ptr(false),
AccountURI: "http://localhost:8080/users/the_mighty_zork", AccountURI: "http://localhost:8080/users/the_mighty_zork",
AccountID: replyingAccount.ID, AccountID: replyingAccount.ID,
InReplyToID: originalStatus.ID, InReplyToID: originalStatus.ID,
@ -324,13 +325,13 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestChainReplyPublicAndUnloc
BoostOfID: "", BoostOfID: "",
ContentWarning: "", ContentWarning: "",
Visibility: gtsmodel.VisibilityPublic, Visibility: gtsmodel.VisibilityPublic,
Sensitive: testrig.FalseBool(), Sensitive: util.Ptr(false),
Language: "en", Language: "en",
CreatedWithApplicationID: "", CreatedWithApplicationID: "",
Federated: testrig.TrueBool(), Federated: util.Ptr(true),
Boostable: testrig.TrueBool(), Boostable: util.Ptr(true),
Replyable: testrig.TrueBool(), Replyable: util.Ptr(true),
Likeable: testrig.TrueBool(), Likeable: util.Ptr(true),
ActivityStreamsType: ap.ObjectNote, ActivityStreamsType: ap.ObjectNote,
} }
if err := suite.db.PutStatus(ctx, firstReplyStatus); err != nil { if err := suite.db.PutStatus(ctx, firstReplyStatus); err != nil {
@ -349,7 +350,7 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestChainReplyPublicAndUnloc
Content: "*nobody", Content: "*nobody",
CreatedAt: testrig.TimeMustParse("2021-09-20T12:42:37+02:00"), CreatedAt: testrig.TimeMustParse("2021-09-20T12:42:37+02:00"),
UpdatedAt: testrig.TimeMustParse("2021-09-20T12:42:37+02:00"), UpdatedAt: testrig.TimeMustParse("2021-09-20T12:42:37+02:00"),
Local: testrig.FalseBool(), Local: util.Ptr(false),
AccountURI: "http://localhost:8080/users/the_mighty_zork", AccountURI: "http://localhost:8080/users/the_mighty_zork",
AccountID: replyingAccount.ID, AccountID: replyingAccount.ID,
InReplyToID: firstReplyStatus.ID, InReplyToID: firstReplyStatus.ID,
@ -358,13 +359,13 @@ func (suite *StatusStatusHomeTimelineableTestSuite) TestChainReplyPublicAndUnloc
BoostOfID: "", BoostOfID: "",
ContentWarning: "", ContentWarning: "",
Visibility: gtsmodel.VisibilityUnlocked, Visibility: gtsmodel.VisibilityUnlocked,
Sensitive: testrig.FalseBool(), Sensitive: util.Ptr(false),
Language: "en", Language: "en",
CreatedWithApplicationID: "", CreatedWithApplicationID: "",
Federated: testrig.TrueBool(), Federated: util.Ptr(true),
Boostable: testrig.TrueBool(), Boostable: util.Ptr(true),
Replyable: testrig.TrueBool(), Replyable: util.Ptr(true),
Likeable: testrig.TrueBool(), Likeable: util.Ptr(true),
ActivityStreamsType: ap.ObjectNote, ActivityStreamsType: ap.ObjectNote,
} }
if err := suite.db.PutStatus(ctx, secondReplyStatus); err != nil { if err := suite.db.PutStatus(ctx, secondReplyStatus); err != nil {

File diff suppressed because it is too large Load diff