find a bug and squish it up and all day long you'll have good luck

This commit is contained in:
tobi 2025-03-17 18:16:59 +01:00
commit f257f779a9
5 changed files with 63 additions and 11 deletions

View file

@ -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
}

View file

@ -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)

View file

@ -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

View file

@ -146,7 +146,7 @@ func (m *Module) prepareProfile(c *gin.Context) *profile {
statusResp, errWithCode := m.processor.Account().WebStatusesGet(
ctx,
account.ID,
false, // mediaOnly = false
mediaOnly,
maxStatusID,
)
if errWithCode != nil {
@ -169,6 +169,11 @@ func (m *Module) prepareProfile(c *gin.Context) *profile {
// mode for the target account profile, and serves that.
func (m *Module) profileGETHandler(c *gin.Context) {
p := m.prepareProfile(c)
if p == nil {
// Something went wrong,
// error already written.
return
}
// Choose desired web renderer for this acct.
switch wrm := p.account.WebLayout; wrm {

View file

@ -92,6 +92,7 @@
aspect-ratio: 4/3;
border: 0;
border-radius: 0;
background: $bg;
}
}