summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/api/client/statuses/statusboost_test.go8
-rw-r--r--internal/db/bundb/migrations/20240722222556_remove_boost_content.go56
-rw-r--r--internal/federation/dereferencing/announce.go9
-rw-r--r--internal/typeutils/internal.go8
-rw-r--r--testrig/testmodels.go6
5 files changed, 68 insertions, 19 deletions
diff --git a/internal/api/client/statuses/statusboost_test.go b/internal/api/client/statuses/statusboost_test.go
index 3e6a5853d..25aa2ea0f 100644
--- a/internal/api/client/statuses/statusboost_test.go
+++ b/internal/api/client/statuses/statusboost_test.go
@@ -80,8 +80,8 @@ func (suite *StatusBoostTestSuite) TestPostBoost() {
suite.False(statusReply.Sensitive)
suite.Equal(apimodel.VisibilityPublic, statusReply.Visibility)
- suite.Equal(targetStatus.ContentWarning, statusReply.SpoilerText)
- suite.Equal(targetStatus.Content, statusReply.Content)
+ suite.Empty(statusReply.SpoilerText)
+ suite.Empty(statusReply.Content)
suite.Equal("the_mighty_zork", statusReply.Account.Username)
suite.Len(statusReply.MediaAttachments, 0)
suite.Len(statusReply.Mentions, 0)
@@ -146,8 +146,8 @@ func (suite *StatusBoostTestSuite) TestPostBoostOwnFollowersOnly() {
suite.False(responseStatus.Sensitive)
suite.Equal(suite.tc.VisToAPIVis(context.Background(), testStatus.Visibility), responseStatus.Visibility)
- suite.Equal(testStatus.ContentWarning, responseStatus.SpoilerText)
- suite.Equal(testStatus.Content, responseStatus.Content)
+ suite.Empty(responseStatus.SpoilerText)
+ suite.Empty(responseStatus.Content)
suite.Equal("the_mighty_zork", responseStatus.Account.Username)
suite.Len(responseStatus.MediaAttachments, 0)
suite.Len(responseStatus.Mentions, 0)
diff --git a/internal/db/bundb/migrations/20240722222556_remove_boost_content.go b/internal/db/bundb/migrations/20240722222556_remove_boost_content.go
new file mode 100644
index 000000000..e9226478b
--- /dev/null
+++ b/internal/db/bundb/migrations/20240722222556_remove_boost_content.go
@@ -0,0 +1,56 @@
+// 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 migrations
+
+import (
+ "context"
+
+ "github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
+ "github.com/uptrace/bun"
+)
+
+// Boosts previously duplicated some columns from their targets.
+// This isn't necessary, so we remove them here.
+// Admins may want to vacuum after running this migration.
+func init() {
+ up := func(ctx context.Context, db *bun.DB) error {
+ return db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error {
+ _, err := tx.NewUpdate().
+ Model((*gtsmodel.Status)(nil)).
+ Where("boost_of_id IS NOT NULL").
+ SetColumn("content", "NULL").
+ SetColumn("content_warning", "NULL").
+ SetColumn("text", "NULL").
+ SetColumn("language", "NULL").
+ SetColumn("sensitive", "FALSE").
+ Exec(ctx)
+
+ return err
+ })
+ }
+
+ down := func(ctx context.Context, db *bun.DB) error {
+ return db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error {
+ return nil
+ })
+ }
+
+ if err := Migrations.Register(up, down); err != nil {
+ panic(err)
+ }
+}
diff --git a/internal/federation/dereferencing/announce.go b/internal/federation/dereferencing/announce.go
index 51f1ffcdd..d786d0695 100644
--- a/internal/federation/dereferencing/announce.go
+++ b/internal/federation/dereferencing/announce.go
@@ -26,6 +26,7 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/id"
+ "github.com/superseriousbusiness/gotosocial/internal/util"
)
// EnrichAnnounce enriches the given boost wrapper status
@@ -78,14 +79,12 @@ func (d *Dereferencer) EnrichAnnounce(
// original URI was an indirect link.
boost.BoostOfURI = target.URI
+ // Boosts are not considered sensitive even if their target is.
+ boost.Sensitive = util.Ptr(false)
+
// Populate remaining fields on
// the boost wrapper using target.
- boost.Content = target.Content
- boost.ContentWarning = target.ContentWarning
boost.ActivityStreamsType = target.ActivityStreamsType
- boost.Sensitive = target.Sensitive
- boost.Language = target.Language
- boost.Text = target.Text
boost.BoostOfID = target.ID
boost.BoostOf = target
boost.BoostOfAccountID = target.AccountID
diff --git a/internal/typeutils/internal.go b/internal/typeutils/internal.go
index 76ec6232c..75da4b27e 100644
--- a/internal/typeutils/internal.go
+++ b/internal/typeutils/internal.go
@@ -81,14 +81,12 @@ func (c *Converter) StatusToBoost(
MentionIDs: []string{},
EmojiIDs: []string{},
+ // Boosts are not considered sensitive even if their target is.
+ Sensitive: util.Ptr(false),
+
// Remaining fields all
// taken from boosted status.
- Content: target.Content,
- ContentWarning: target.ContentWarning,
ActivityStreamsType: target.ActivityStreamsType,
- Sensitive: util.Ptr(*target.Sensitive),
- Language: target.Language,
- Text: target.Text,
BoostOfID: target.ID,
BoostOf: target,
BoostOfAccountID: target.AccountID,
diff --git a/testrig/testmodels.go b/testrig/testmodels.go
index 044922602..87f8c7054 100644
--- a/testrig/testmodels.go
+++ b/testrig/testmodels.go
@@ -1488,8 +1488,6 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
ID: "01G36SF3V6Y6V5BF9P4R7PQG7G",
URI: "http://localhost:8080/users/admin/statuses/01G36SF3V6Y6V5BF9P4R7PQG7G",
URL: "http://localhost:8080/@admin/statuses/01G36SF3V6Y6V5BF9P4R7PQG7G",
- Content: "hello everyone!",
- Text: "hello everyone!",
CreatedAt: TimeMustParse("2021-10-20T12:41:37+02:00"),
UpdatedAt: TimeMustParse("2021-10-20T12:41:37+02:00"),
Local: util.Ptr(true),
@@ -1501,10 +1499,8 @@ func NewTestStatuses() map[string]*gtsmodel.Status {
BoostOfID: "01F8MHAMCHF6Y650WCRSCP4WMY",
BoostOfAccountID: "01F8MH1H7YV1Z7D2C8K2730QBF",
ThreadID: "",
- ContentWarning: "introduction post",
Visibility: gtsmodel.VisibilityPublic,
- Sensitive: util.Ptr(true),
- Language: "en",
+ Sensitive: util.Ptr(false),
CreatedWithApplicationID: "01F8MGXQRHYF5QPMTMXP78QC2F",
Federated: util.Ptr(true),
ActivityStreamsType: ap.ObjectNote,