[bugfix] Allow instance accounts to be shown in search results in certain circumstances (#2053)

This commit is contained in:
tobi 2023-08-02 09:31:09 +02:00 committed by GitHub
commit cec29e2a8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 203 additions and 15 deletions

View file

@ -44,6 +44,13 @@ func (p *Processor) Lookup(
requestingAccount *gtsmodel.Account,
query string,
) (*apimodel.Account, gtserror.WithCode) {
// Include instance accounts in this search.
//
// Lookup is for one specific account so we
// can't return loads of instance accounts by
// accident.
const includeInstanceAccounts = true
// Validate query.
query = strings.TrimSpace(query)
if query == "" {
@ -96,7 +103,12 @@ func (p *Processor) Lookup(
// using the packageAccounts function to return it. This
// may cause the account to be filtered out if it's not
// visible to the caller, so anticipate this.
accounts, errWithCode := p.packageAccounts(ctx, requestingAccount, []*gtsmodel.Account{account})
accounts, errWithCode := p.packageAccounts(
ctx,
requestingAccount,
[]*gtsmodel.Account{account},
includeInstanceAccounts,
)
if errWithCode != nil {
return nil, errWithCode
}