Update ApiV1Controller and DiscoverController, fix postgres hashtag search

This commit is contained in:
Daniel Supernault 2023-05-02 23:26:37 -06:00
parent 55293e9ee6
commit 055aa6b39f
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 15 additions and 4 deletions

View file

@ -3245,9 +3245,15 @@ class ApiV1Controller extends Controller
'limit' => 'nullable|integer|max:100'
]);
$tag = Hashtag::whereName($hashtag)
->orWhere('slug', $hashtag)
->first();
if(config('database.default') === 'pgsql') {
$tag = Hashtag::where('name', 'ilike', $hashtag)
->orWhere('slug', 'ilike', $hashtag)
->first();
} else {
$tag = Hashtag::whereName($hashtag)
->orWhere('slug', $hashtag)
->first();
}
if(!$tag) {
return response()->json([]);

View file

@ -61,7 +61,12 @@ class DiscoverController extends Controller
$end = $page > 1 ? $page * 9 : 0;
$tag = $request->input('hashtag');
$hashtag = Hashtag::whereName($tag)->firstOrFail();
if(config('database.default') === 'pgsql') {
$hashtag = Hashtag::where('name', 'ilike', $tag)->firstOrFail();
} else {
$hashtag = Hashtag::whereName($tag)->firstOrFail();
}
if($hashtag->is_banned == true) {
return [];
}