Files
kim 7362d55a35 [feature] add deleted flag to the statuses table to track tombstones (#4716)
# Description

- replaces a bunch of boolean (and like) columns with a single "statuses.flags" column
- adds a potential deleted value for the new "statuses.flags" column
- replaces useless migration.Down functions with empty txs with empty functions

In a future PR this will update our status deletion logic to instead stub-out a particular status row instead of deleting it, where necessary, to maintain status threads. In the process of replacing a bunch of columns with a single bit field this should also free up some storage space on the statuses table! It also replaces a bunch of indices with partials which again should further reduce space! ~~This is yet to be tested, so we shall see :p~~

Just finished testing this on my own instance...
- previous database size: 24827580416
- after database size: 21751169024

So 3GB of savings from a 24GB database, that's pretty damn impressive!

## Checklist

- [x] I/we have read the [GoToSocial contribution guidelines](https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/CONTRIBUTING.md).
- [x] I/we have not used so-called 'AI' to create the proposed changes.
- [x] I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat.
- [x] I/we have performed a self-review of added code.
- [x] I/we have written code that is legible and maintainable by others.
- [x] I/we have commented the added code, particularly in hard-to-understand areas.
- [ ] I/we have made any necessary changes to documentation.
- [ ] I/we have added tests that cover new code.
- [x] I/we have run tests and they pass locally with the changes.
- [x] I/we have run `go fmt ./...` and `golangci-lint run`.

Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4716
Co-authored-by: kim <grufwub@gmail.com>
Co-committed-by: kim <grufwub@gmail.com>
2026-03-10 10:15:19 +01:00

89 lines
2.5 KiB
Go

// 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 interactionrequests_test
import (
"testing"
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
"code.superseriousbusiness.org/gotosocial/internal/processing/interactionrequests"
"code.superseriousbusiness.org/gotosocial/testrig"
"github.com/stretchr/testify/suite"
)
type AcceptTestSuite struct {
InteractionRequestsTestSuite
}
func (suite *AcceptTestSuite) TestAccept() {
testStructs := testrig.SetupTestStructs(rMediaPath, rTemplatePath)
defer testrig.TearDownTestStructs(testStructs)
var (
ctx = suite.T().Context()
state = testStructs.State
acct = suite.testAccounts["local_account_2"]
intReq = suite.testInteractionRequests["admin_account_reply_turtle"]
)
// Create interaction reqs processor.
p := interactionrequests.New(
testStructs.Common,
testStructs.State,
testStructs.TypeConverter,
)
apiReq, errWithCode := p.Accept(ctx, acct, intReq.ID)
if errWithCode != nil {
suite.FailNow(errWithCode.Error())
}
// Get db interaction request.
dbReq, err := state.DB.GetInteractionRequestByID(ctx, apiReq.ID)
if err != nil {
suite.FailNow(err.Error())
}
suite.True(dbReq.IsAccepted())
// Interacting status
// should now be approved.
dbStatus, err := state.DB.GetStatusByURI(ctx, dbReq.InteractionURI)
if err != nil {
suite.FailNow(err.Error())
}
suite.False(dbStatus.Flags.PendingApproval())
suite.Equal(dbReq.AuthorizationURI, dbStatus.ApprovedByURI)
// Wait for a notification
// for interacting status.
testrig.WaitFor(func() bool {
notif, err := state.DB.GetNotification(
ctx,
gtsmodel.NotificationMention,
dbStatus.InReplyToAccountID,
dbStatus.AccountID,
dbStatus.ID,
)
return notif != nil && err == nil
})
}
func TestAcceptTestSuite(t *testing.T) {
suite.Run(t, new(AcceptTestSuite))
}