[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

@ -48,11 +48,12 @@ func (p *Processor) packageAccounts(
ctx context.Context,
requestingAccount *gtsmodel.Account,
accounts []*gtsmodel.Account,
includeInstanceAccounts bool,
) ([]*apimodel.Account, gtserror.WithCode) {
apiAccounts := make([]*apimodel.Account, 0, len(accounts))
for _, account := range accounts {
if account.IsInstance() {
if !includeInstanceAccounts && account.IsInstance() {
// No need to show instance accounts.
continue
}
@ -169,8 +170,9 @@ func (p *Processor) packageSearchResult(
statuses []*gtsmodel.Status,
tags []*gtsmodel.Tag,
v1 bool,
includeInstanceAccounts bool,
) (*apimodel.SearchResult, gtserror.WithCode) {
apiAccounts, errWithCode := p.packageAccounts(ctx, requestingAccount, accounts)
apiAccounts, errWithCode := p.packageAccounts(ctx, requestingAccount, accounts, includeInstanceAccounts)
if errWithCode != nil {
return nil, errWithCode
}