mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-26 02:53:32 -06:00
find a bug and squish it up and all day long you'll have good luck
This commit is contained in:
parent
c72938bcc8
commit
f257f779a9
5 changed files with 63 additions and 11 deletions
|
|
@ -1054,10 +1054,7 @@ func (a *accountDB) GetAccountWebStatuses(
|
|||
TableExpr("? AS ?", bun.Ident("statuses"), bun.Ident("status")).
|
||||
// Select only IDs from table
|
||||
Column("status.id").
|
||||
Where("? = ?", bun.Ident("status.account_id"), account.ID).
|
||||
// Don't show replies or boosts.
|
||||
Where("? IS NULL", bun.Ident("status.in_reply_to_uri")).
|
||||
Where("? IS NULL", bun.Ident("status.boost_of_id"))
|
||||
Where("? = ?", bun.Ident("status.account_id"), account.ID)
|
||||
|
||||
// Select statuses for this account according
|
||||
// to their web visibility preference.
|
||||
|
|
@ -1082,15 +1079,19 @@ func (a *accountDB) GetAccountWebStatuses(
|
|||
)
|
||||
}
|
||||
|
||||
// Don't show local-only statuses on the web view.
|
||||
q = q.Where("? = ?", bun.Ident("status.federated"), true)
|
||||
// Don't show replies, boosts, or
|
||||
// local-only statuses on the web view.
|
||||
q = q.
|
||||
Where("? IS NULL", bun.Ident("status.in_reply_to_uri")).
|
||||
Where("? IS NULL", bun.Ident("status.boost_of_id")).
|
||||
Where("? = ?", bun.Ident("status.federated"), true)
|
||||
|
||||
// Respect media-only preference.
|
||||
if mediaOnly {
|
||||
q = qMediaOnly(ctx, q)
|
||||
}
|
||||
|
||||
// return only statuses LOWER (ie., older) than maxID
|
||||
// Return only statuses LOWER (ie., older) than maxID
|
||||
if maxID == "" {
|
||||
maxID = id.Highest
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,12 @@ func (suite *AccountTestSuite) TestGetAccountStatuses() {
|
|||
suite.Len(statuses, 9)
|
||||
}
|
||||
|
||||
func (suite *AccountTestSuite) TestGetAccountWebStatusesMediaOnly() {
|
||||
statuses, err := suite.db.GetAccountWebStatuses(context.Background(), suite.testAccounts["local_account_3"], true, 20, "")
|
||||
suite.NoError(err)
|
||||
suite.Len(statuses, 2)
|
||||
}
|
||||
|
||||
func (suite *AccountTestSuite) TestGetAccountStatusesPageDown() {
|
||||
// get the first page
|
||||
statuses, err := suite.db.GetAccountStatuses(context.Background(), suite.testAccounts["local_account_1"].ID, 3, false, false, "", "", false, false)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ package migrations
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
|
|
@ -29,14 +29,53 @@ func init() {
|
|||
return db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error {
|
||||
|
||||
// Add new column to settings.
|
||||
if _, err := tx.NewAddColumn().
|
||||
if _, err := tx.
|
||||
NewAddColumn().
|
||||
Table("account_settings").
|
||||
ColumnExpr(
|
||||
"? SMALLINT NOT NULL DEFAULT ?",
|
||||
bun.Ident("web_layout"), 1,
|
||||
).
|
||||
Exec(ctx); err != nil {
|
||||
return gtserror.Newf("error adding account_settings.web_layout: %w", err)
|
||||
return err
|
||||
}
|
||||
|
||||
// Drop existing statuses web index as it's out of date.
|
||||
log.Info(ctx, "updating statuses_profile_web_view_idx, this may take a while, please wait!")
|
||||
if _, err := tx.
|
||||
NewDropIndex().
|
||||
Index("statuses_profile_web_view_idx").
|
||||
IfExists().
|
||||
Exec(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := tx.
|
||||
NewCreateIndex().
|
||||
Table("statuses").
|
||||
Index("statuses_profile_web_view_idx").
|
||||
Column(
|
||||
"account_id",
|
||||
"visibility",
|
||||
"in_reply_to_uri",
|
||||
"boost_of_id",
|
||||
"federated",
|
||||
"attachments",
|
||||
).
|
||||
IfNotExists().
|
||||
Exec(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := tx.
|
||||
NewCreateIndex().
|
||||
Table("statuses").
|
||||
Index("statuses_profile_web_view_sorting_idx").
|
||||
Column("account_id", "federated").
|
||||
ColumnExpr("? DESC", bun.Ident("id")).
|
||||
IfNotExists().
|
||||
Exec(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue