summaryrefslogtreecommitdiff
path: root/internal/visibility/statusvisible.go
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-07-05 13:23:03 +0200
committerLibravatar GitHub <noreply@github.com>2021-07-05 13:23:03 +0200
commitd389e7b150df6ecd215c7b661b294ea153ad0103 (patch)
tree8739e3103cb5130875d903cc7fc72fd9db3b8434 /internal/visibility/statusvisible.go
parentFix 404 contact (#74) (diff)
downloadgotosocial-d389e7b150df6ecd215c7b661b294ea153ad0103.tar.xz
Domain block (#76)
* start work on admin domain blocking * move stuff around + further work on domain blocks * move + restructure processor * prep work for deleting account * tidy * go fmt * formatting * domain blocking more work * check domain blocks way earlier on * progress on delete account * delete more stuff when an account is gone * and more... * domain blocky block block * get individual domain block, delete a block
Diffstat (limited to 'internal/visibility/statusvisible.go')
-rw-r--r--internal/visibility/statusvisible.go27
1 files changed, 24 insertions, 3 deletions
diff --git a/internal/visibility/statusvisible.go b/internal/visibility/statusvisible.go
index c022be359..dc6b74702 100644
--- a/internal/visibility/statusvisible.go
+++ b/internal/visibility/statusvisible.go
@@ -19,9 +19,20 @@ func (f *filter) StatusVisible(targetStatus *gtsmodel.Status, requestingAccount
relevantAccounts, err := f.pullRelevantAccountsFromStatus(targetStatus)
if err != nil {
l.Debugf("error pulling relevant accounts for status %s: %s", targetStatus.ID, err)
+ return false, fmt.Errorf("error pulling relevant accounts for status %s: %s", targetStatus.ID, err)
+ }
+
+ domainBlocked, err := f.domainBlockedRelevant(relevantAccounts)
+ if err != nil {
+ l.Debugf("error checking domain block: %s", err)
+ return false, fmt.Errorf("error checking domain block: %s", err)
}
- targetAccount := relevantAccounts.StatusAuthor
+ if domainBlocked {
+ return false, nil
+ }
+
+ targetAccount := relevantAccounts.StatusAuthor
// if target account is suspended then don't show the status
if !targetAccount.SuspendedAt.IsZero() {
l.Trace("target account suspended at is not zero")
@@ -123,8 +134,8 @@ func (f *filter) StatusVisible(targetStatus *gtsmodel.Status, requestingAccount
}
// status boosts accounts id
- if relevantAccounts.BoostedAccount != nil {
- if blocked, err := f.db.Blocked(relevantAccounts.BoostedAccount.ID, requestingAccount.ID); err != nil {
+ if relevantAccounts.BoostedStatusAuthor != nil {
+ if blocked, err := f.db.Blocked(relevantAccounts.BoostedStatusAuthor.ID, requestingAccount.ID); err != nil {
return false, err
} else if blocked {
l.Trace("a block exists between requesting account and boosted account")
@@ -152,6 +163,16 @@ func (f *filter) StatusVisible(targetStatus *gtsmodel.Status, requestingAccount
}
}
+ // boost mentions accounts
+ for _, a := range relevantAccounts.BoostedMentionedAccounts {
+ if blocked, err := f.db.Blocked(a.ID, requestingAccount.ID); err != nil {
+ return false, err
+ } else if blocked {
+ l.Trace("a block exists between requesting account and a boosted mentioned account")
+ return false, nil
+ }
+ }
+
// if the requesting account is mentioned in the status it should always be visible
for _, acct := range relevantAccounts.MentionedAccounts {
if acct.ID == requestingAccount.ID {