domain blocking more work

This commit is contained in:
tsmethurst 2021-06-30 12:02:28 +02:00
commit 99eb3bf564
11 changed files with 160 additions and 58 deletions

View file

@ -3,6 +3,7 @@ package visibility
import (
"fmt"
"github.com/superseriousbusiness/gotosocial/internal/db"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
)
@ -79,3 +80,20 @@ type relevantAccounts struct {
BoostedReplyToAccount *gtsmodel.Account
MentionedAccounts []*gtsmodel.Account
}
func (f *filter) blockedDomain(host string) (bool, error) {
b := &gtsmodel.DomainBlock{}
err := f.db.GetWhere([]db.Where{{Key: "domain", Value: host, CaseInsensitive: true}}, b)
if err == nil {
// block exists
return true, nil
}
if _, ok := err.(db.ErrNoEntries); ok {
// there are no entries so there's no block
return false, nil
}
// there's an actual error
return false, err
}