Explorar o código

Update SearchApiV2Service, improve postgres support

Daniel Supernault %!s(int64=2) %!d(string=hai) anos
pai
achega
666e5732a5
Modificáronse 1 ficheiros con 6 adicións e 5 borrados
  1. 6 5
      app/Services/SearchApiV2Service.php

+ 6 - 5
app/Services/SearchApiV2Service.php

@@ -96,9 +96,10 @@ class SearchApiV2Service
 			$webfingerQuery = '@' . $webfingerQuery;
 			$webfingerQuery = '@' . $webfingerQuery;
 		}
 		}
 		$banned = InstanceService::getBannedDomains();
 		$banned = InstanceService::getBannedDomains();
+		$operator = config('database.default') === 'pgsql' ? 'ilike' : 'like';
 		$results = Profile::select('username', 'id', 'followers_count', 'domain')
 		$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')
 			->orderByDesc('profiles.followers_count')
 			->offset($offset)
 			->offset($offset)
 			->limit($limit)
 			->limit($limit)
@@ -161,11 +162,11 @@ class SearchApiV2Service
 	protected function statusesById()
 	protected function statusesById()
 	{
 	{
 		$mastodonMode = self::$mastodonMode;
 		$mastodonMode = self::$mastodonMode;
-		$accountId = $this->query->input('account_id');
 		$limit = $this->query->input('limit', 20);
 		$limit = $this->query->input('limit', 20);
 		$query = '%' . $this->query->input('q') . '%';
 		$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)
 			->limit($limit)
 			->get()
 			->get()
 			->map(function($status) use($mastodonMode) {
 			->map(function($status) use($mastodonMode) {