mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-02-05 07:37:02 +01:00
check boosted account ID when performing usermute checks (#3708)
This commit is contained in:
parent
b3ecfe1e0a
commit
527587155a
2 changed files with 41 additions and 2 deletions
|
@ -943,8 +943,9 @@ func (c *Converter) statusToAPIFilterResults(
|
||||||
// Both mutes and filters can expire.
|
// Both mutes and filters can expire.
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
// If the requesting account mutes the account that created this status, hide the status.
|
// If requesting account mutes the author (taking boosts into account), hide it.
|
||||||
if mutes.Matches(s.AccountID, filterContext, now) {
|
if (s.BoostOfAccountID != "" && mutes.Matches(s.AccountID, filterContext, now)) ||
|
||||||
|
mutes.Matches(s.AccountID, filterContext, now) {
|
||||||
return nil, statusfilter.ErrHideStatus
|
return nil, statusfilter.ErrHideStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1161,6 +1161,7 @@ func (suite *InternalToFrontendTestSuite) TestHashtagAnywhereFilteredBoostToFron
|
||||||
func (suite *InternalToFrontendTestSuite) TestMutedStatusToFrontend() {
|
func (suite *InternalToFrontendTestSuite) TestMutedStatusToFrontend() {
|
||||||
testStatus := suite.testStatuses["admin_account_status_1"]
|
testStatus := suite.testStatuses["admin_account_status_1"]
|
||||||
requestingAccount := suite.testAccounts["local_account_1"]
|
requestingAccount := suite.testAccounts["local_account_1"]
|
||||||
|
|
||||||
mutes := usermute.NewCompiledUserMuteList([]*gtsmodel.UserMute{
|
mutes := usermute.NewCompiledUserMuteList([]*gtsmodel.UserMute{
|
||||||
{
|
{
|
||||||
AccountID: requestingAccount.ID,
|
AccountID: requestingAccount.ID,
|
||||||
|
@ -1168,6 +1169,7 @@ func (suite *InternalToFrontendTestSuite) TestMutedStatusToFrontend() {
|
||||||
Notifications: util.Ptr(false),
|
Notifications: util.Ptr(false),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
_, err := suite.typeconverter.StatusToAPIStatus(
|
_, err := suite.typeconverter.StatusToAPIStatus(
|
||||||
context.Background(),
|
context.Background(),
|
||||||
testStatus,
|
testStatus,
|
||||||
|
@ -1186,6 +1188,7 @@ func (suite *InternalToFrontendTestSuite) TestMutedReplyStatusToFrontend() {
|
||||||
testStatus.InReplyToID = suite.testStatuses["local_account_2_status_1"].ID
|
testStatus.InReplyToID = suite.testStatuses["local_account_2_status_1"].ID
|
||||||
testStatus.InReplyToAccountID = mutedAccount.ID
|
testStatus.InReplyToAccountID = mutedAccount.ID
|
||||||
requestingAccount := suite.testAccounts["local_account_1"]
|
requestingAccount := suite.testAccounts["local_account_1"]
|
||||||
|
|
||||||
mutes := usermute.NewCompiledUserMuteList([]*gtsmodel.UserMute{
|
mutes := usermute.NewCompiledUserMuteList([]*gtsmodel.UserMute{
|
||||||
{
|
{
|
||||||
AccountID: requestingAccount.ID,
|
AccountID: requestingAccount.ID,
|
||||||
|
@ -1193,11 +1196,46 @@ func (suite *InternalToFrontendTestSuite) TestMutedReplyStatusToFrontend() {
|
||||||
Notifications: util.Ptr(false),
|
Notifications: util.Ptr(false),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// Populate status so the converter has the account objects it needs for muting.
|
// Populate status so the converter has the account objects it needs for muting.
|
||||||
err := suite.db.PopulateStatus(context.Background(), testStatus)
|
err := suite.db.PopulateStatus(context.Background(), testStatus)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
suite.FailNow(err.Error())
|
suite.FailNow(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert the status to API format, which should fail.
|
||||||
|
_, err = suite.typeconverter.StatusToAPIStatus(
|
||||||
|
context.Background(),
|
||||||
|
testStatus,
|
||||||
|
requestingAccount,
|
||||||
|
statusfilter.FilterContextHome,
|
||||||
|
nil,
|
||||||
|
mutes,
|
||||||
|
)
|
||||||
|
suite.ErrorIs(err, statusfilter.ErrHideStatus)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *InternalToFrontendTestSuite) TestMutedBoostStatusToFrontend() {
|
||||||
|
mutedAccount := suite.testAccounts["local_account_2"]
|
||||||
|
testStatus := suite.testStatuses["admin_account_status_1"]
|
||||||
|
testStatus.BoostOfID = suite.testStatuses["local_account_2_status_1"].ID
|
||||||
|
testStatus.BoostOfAccountID = mutedAccount.ID
|
||||||
|
requestingAccount := suite.testAccounts["local_account_1"]
|
||||||
|
|
||||||
|
mutes := usermute.NewCompiledUserMuteList([]*gtsmodel.UserMute{
|
||||||
|
{
|
||||||
|
AccountID: requestingAccount.ID,
|
||||||
|
TargetAccountID: mutedAccount.ID,
|
||||||
|
Notifications: util.Ptr(false),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
// Populate status so the converter has the account objects it needs for muting.
|
||||||
|
err := suite.db.PopulateStatus(context.Background(), testStatus)
|
||||||
|
if err != nil {
|
||||||
|
suite.FailNow(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
// Convert the status to API format, which should fail.
|
// Convert the status to API format, which should fail.
|
||||||
_, err = suite.typeconverter.StatusToAPIStatus(
|
_, err = suite.typeconverter.StatusToAPIStatus(
|
||||||
context.Background(),
|
context.Background(),
|
||||||
|
|
Loading…
Reference in a new issue