From 666e5732a5c15a77a3a4a71abf6849e2c9671d0a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 5 May 2023 02:10:07 -0600 Subject: [PATCH] Update SearchApiV2Service, improve postgres support --- app/Services/SearchApiV2Service.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/Services/SearchApiV2Service.php b/app/Services/SearchApiV2Service.php index 93a29cae9..f89fe58b1 100644 --- a/app/Services/SearchApiV2Service.php +++ b/app/Services/SearchApiV2Service.php @@ -96,9 +96,10 @@ class SearchApiV2Service $webfingerQuery = '@' . $webfingerQuery; } $banned = InstanceService::getBannedDomains(); + $operator = config('database.default') === 'pgsql' ? 'ilike' : 'like'; $results = Profile::select('username', 'id', 'followers_count', 'domain') - ->where('username', 'like', $query) - ->orWhere('webfinger', 'like', $webfingerQuery) + ->where('username', $operator, $query) + ->orWhere('webfinger', $operator, $webfingerQuery) ->orderByDesc('profiles.followers_count') ->offset($offset) ->limit($limit) @@ -161,11 +162,11 @@ class SearchApiV2Service protected function statusesById() { $mastodonMode = self::$mastodonMode; - $accountId = $this->query->input('account_id'); $limit = $this->query->input('limit', 20); $query = '%' . $this->query->input('q') . '%'; - $results = Status::where('caption', 'like', $query) - ->whereProfileId($accountId) + $operator = config('database.default') === 'pgsql' ? 'ilike' : 'like'; + $results = Status::where('caption', $operator, $query) + ->whereProfileId(request()->user()->profile_id) ->limit($limit) ->get() ->map(function($status) use($mastodonMode) {