diff --git a/app/Services/SearchApiV2Service.php b/app/Services/SearchApiV2Service.php index f17fe3e84..6d28c949f 100644 --- a/app/Services/SearchApiV2Service.php +++ b/app/Services/SearchApiV2Service.php @@ -132,7 +132,6 @@ class SearchApiV2Service $q = $this->query->input('q'); $limit = $this->query->input('limit') ?? 20; $offset = $this->query->input('offset') ?? 0; - $query = Str::startsWith($q, '#') ? substr($q, 1) : $q; $query = $query.'%'; @@ -214,6 +213,9 @@ class SearchApiV2Service $user = request()->user(); $mastodonMode = self::$mastodonMode; $query = urldecode($this->query->input('q')); + $limit = $this->query->input('limit') ?? 20; + $offset = $this->query->input('offset') ?? 0; + $banned = InstanceService::getBannedDomains(); $domainBlocks = UserFilterService::domainBlocks($user->profile_id); if ($domainBlocks && count($domainBlocks)) { @@ -252,7 +254,12 @@ class SearchApiV2Service if (in_array($domain, $banned)) { return $default; } - $default['accounts'][] = $res; + $paginated = collect($res)->take($limit)->skip($offset)->toArray(); + if (! empty($paginated)) { + $default['accounts'][] = $paginated; + } else { + $default['accounts'] = []; + } return $default; } else { @@ -271,7 +278,12 @@ class SearchApiV2Service if (in_array($domain, $banned)) { return $default; } - $default['accounts'][] = $res; + $paginated = collect($res)->take($limit)->skip($offset)->toArray(); + if (! empty($paginated)) { + $default['accounts'][] = $paginated; + } else { + $default['accounts'] = []; + } return $default; } else {