summaryrefslogtreecommitdiff
path: root/internal/processing/search/accounts.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-08-02 09:31:09 +0200
committerLibravatar GitHub <noreply@github.com>2023-08-02 08:31:09 +0100
commitcec29e2a8d2d6ca49bb6c789f0ed3226849a7359 (patch)
tree042ba1ddd9d42552403b3a00e224e45e498b962a /internal/processing/search/accounts.go
parent[feature] Allow users to skip http client tls verification for testing purpos... (diff)
downloadgotosocial-cec29e2a8d2d6ca49bb6c789f0ed3226849a7359.tar.xz
[bugfix] Allow instance accounts to be shown in search results in certain circumstances (#2053)
Diffstat (limited to 'internal/processing/search/accounts.go')
-rw-r--r--internal/processing/search/accounts.go21
1 files changed, 19 insertions, 2 deletions
diff --git a/internal/processing/search/accounts.go b/internal/processing/search/accounts.go
index eb88647a3..cfcc65b2b 100644
--- a/internal/processing/search/accounts.go
+++ b/internal/processing/search/accounts.go
@@ -49,6 +49,13 @@ func (p *Processor) Accounts(
resolve bool,
following bool,
) ([]*apimodel.Account, gtserror.WithCode) {
+ // Don't include instance accounts in this search.
+ //
+ // We don't want someone to start typing '@mastodon'
+ // and then get a million instance service accounts
+ // in their search results.
+ const includeInstanceAccounts = false
+
var (
foundAccounts = make([]*gtsmodel.Account, 0, limit)
appendAccount = func(foundAccount *gtsmodel.Account) { foundAccounts = append(foundAccounts, foundAccount) }
@@ -83,7 +90,12 @@ func (p *Processor) Accounts(
// if caller supplied an offset greater than 0, return
// nothing as though there were no additional results.
if offset > 0 {
- return p.packageAccounts(ctx, requestingAccount, foundAccounts)
+ return p.packageAccounts(
+ ctx,
+ requestingAccount,
+ foundAccounts,
+ includeInstanceAccounts,
+ )
}
// Return all accounts we can find that match the
@@ -106,5 +118,10 @@ func (p *Processor) Accounts(
}
// Return whatever we got (if anything).
- return p.packageAccounts(ctx, requestingAccount, foundAccounts)
+ return p.packageAccounts(
+ ctx,
+ requestingAccount,
+ foundAccounts,
+ includeInstanceAccounts,
+ )
}