summaryrefslogtreecommitdiff
path: root/internal/processing/account
diff options
context:
space:
mode:
authorLibravatar Daenney <daenney@users.noreply.github.com>2023-08-07 19:38:11 +0200
committerLibravatar GitHub <noreply@github.com>2023-08-07 18:38:11 +0100
commitbe3718f6e4c7bb229f9eb78b44c52d14399977cc (patch)
treea0efc132fbfb806227cc4b9af8bac9f5a5775c1c /internal/processing/account
parent[chore]: Bump github.com/tdewolff/minify/v2 from 2.12.7 to 2.12.8 (#2073) (diff)
downloadgotosocial-be3718f6e4c7bb229f9eb78b44c52d14399977cc.tar.xz
[chore] Use generic pointer function (#2080)
This replaces the different $TypePtr functions with a generic implementation.
Diffstat (limited to 'internal/processing/account')
-rw-r--r--internal/processing/account/delete.go15
-rw-r--r--internal/processing/account/follow_test.go21
2 files changed, 15 insertions, 21 deletions
diff --git a/internal/processing/account/delete.go b/internal/processing/account/delete.go
index dd5957531..d2483aeb1 100644
--- a/internal/processing/account/delete.go
+++ b/internal/processing/account/delete.go
@@ -31,6 +31,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/log"
"github.com/superseriousbusiness/gotosocial/internal/messages"
+ "github.com/superseriousbusiness/gotosocial/internal/util"
"golang.org/x/crypto/bcrypt"
)
@@ -427,10 +428,8 @@ func (p *Processor) deleteAccountPeripheral(ctx context.Context, account *gtsmod
// names of all columns that are updated by it.
func stubbifyAccount(account *gtsmodel.Account, origin string) []string {
var (
- falseBool = func() *bool { b := false; return &b }
- trueBool = func() *bool { b := true; return &b }
- now = time.Now()
- never = time.Time{}
+ now = time.Now()
+ never = time.Time{}
)
account.FetchedAt = never
@@ -444,17 +443,17 @@ func stubbifyAccount(account *gtsmodel.Account, origin string) []string {
account.Fields = nil
account.Note = ""
account.NoteRaw = ""
- account.Memorial = falseBool()
+ account.Memorial = util.Ptr(false)
account.AlsoKnownAs = ""
account.MovedToAccountID = ""
account.Reason = ""
- account.Discoverable = falseBool()
+ account.Discoverable = util.Ptr(false)
account.StatusContentType = ""
account.CustomCSS = ""
account.SuspendedAt = now
account.SuspensionOrigin = origin
- account.HideCollections = trueBool()
- account.EnableRSS = falseBool()
+ account.HideCollections = util.Ptr(true)
+ account.EnableRSS = util.Ptr(false)
return []string{
"fetched_at",
diff --git a/internal/processing/account/follow_test.go b/internal/processing/account/follow_test.go
index 70a28eea2..ed6b62304 100644
--- a/internal/processing/account/follow_test.go
+++ b/internal/processing/account/follow_test.go
@@ -23,7 +23,7 @@ import (
"github.com/stretchr/testify/suite"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
- "github.com/superseriousbusiness/gotosocial/testrig"
+ "github.com/superseriousbusiness/gotosocial/internal/util"
)
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')
relationship, err := suite.accountProcessor.FollowCreate(ctx, requestingAccount, &apimodel.AccountFollowRequest{
ID: targetAccount.ID,
- Reblogs: testrig.FalseBool(),
- Notify: testrig.TrueBool(),
+ Reblogs: util.Ptr(false),
+ Notify: util.Ptr(true),
})
-
if err != nil {
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')
relationship, err := suite.accountProcessor.FollowCreate(ctx, requestingAccount, &apimodel.AccountFollowRequest{
ID: targetAccount.ID,
- Notify: testrig.TrueBool(),
+ Notify: util.Ptr(true),
})
-
if err != nil {
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')
relationship, err := suite.accountProcessor.FollowCreate(ctx, requestingAccount, &apimodel.AccountFollowRequest{
ID: targetAccount.ID,
- Notify: testrig.TrueBool(),
- Reblogs: testrig.TrueBool(),
+ Notify: util.Ptr(true),
+ Reblogs: util.Ptr(true),
})
-
if err != nil {
suite.FailNow(err.Error())
}
@@ -104,10 +101,9 @@ func (suite *FollowTestSuite) TestUpdateExistingFollowChangeNothing() {
// Trace logs should show no update query.
relationship, err := suite.accountProcessor.FollowCreate(ctx, requestingAccount, &apimodel.AccountFollowRequest{
ID: targetAccount.ID,
- Notify: testrig.FalseBool(),
- Reblogs: testrig.TrueBool(),
+ Notify: util.Ptr(false),
+ Reblogs: util.Ptr(true),
})
-
if err != nil {
suite.FailNow(err.Error())
}
@@ -126,7 +122,6 @@ func (suite *FollowTestSuite) TestUpdateExistingFollowSetNothing() {
relationship, err := suite.accountProcessor.FollowCreate(ctx, requestingAccount, &apimodel.AccountFollowRequest{
ID: targetAccount.ID,
})
-
if err != nil {
suite.FailNow(err.Error())
}