summaryrefslogtreecommitdiff
path: root/internal/processing/search.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-02-14 11:55:02 +0100
committerLibravatar GitHub <noreply@github.com>2023-02-14 11:55:02 +0100
commit6c6f0422903209377198da76daa06c041a362a68 (patch)
treef0ba7f3b932181c80d5ccc6254ee51fd5eb8fcc8 /internal/processing/search.go
parent[bugfix] Fix up `error getting account avatar/header` errors, other small fix... (diff)
downloadgotosocial-6c6f0422903209377198da76daa06c041a362a68.tar.xz
[bugfix] Return empty result rather than 500 error when searching for blocked domains (#1498)
* [bugfix] Return empty result when searching for blocked domains * add tests
Diffstat (limited to 'internal/processing/search.go')
-rw-r--r--internal/processing/search.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/processing/search.go b/internal/processing/search.go
index 6db938b37..90e361cf7 100644
--- a/internal/processing/search.go
+++ b/internal/processing/search.go
@@ -87,6 +87,15 @@ func (p *processor) SearchGet(ctx context.Context, authed *oauth.Auth, search *a
if username, domain, err := util.ExtractNamestringParts(maybeNamestring); err == nil {
l.Trace("search term is a mention, looking it up...")
+ blocked, err := p.db.IsDomainBlocked(ctx, domain)
+ if err != nil {
+ return nil, gtserror.NewErrorInternalError(fmt.Errorf("error checking domain block: %w", err))
+ }
+ if blocked {
+ l.Debug("domain is blocked")
+ return searchResult, nil
+ }
+
foundAccount, err := p.searchAccountByUsernameDomain(ctx, authed, username, domain, search.Resolve)
if err != nil {
var errNotRetrievable *dereferencing.ErrNotRetrievable
@@ -110,6 +119,15 @@ func (p *processor) SearchGet(ctx context.Context, authed *oauth.Auth, search *a
if uri, err := url.Parse(query); err == nil {
if uri.Scheme == "https" || uri.Scheme == "http" {
l.Trace("search term is a uri, looking it up...")
+ blocked, err := p.db.IsURIBlocked(ctx, uri)
+ if err != nil {
+ return nil, gtserror.NewErrorInternalError(fmt.Errorf("error checking domain block: %w", err))
+ }
+ if blocked {
+ l.Debug("domain is blocked")
+ return searchResult, nil
+ }
+
// check if it's a status...
foundStatus, err := p.searchStatusByURI(ctx, authed, uri)
if err != nil {