Update ApiV1Controller and DiscoverController, fix postgres hashtag search

pull/4342/head
Daniel Supernault 2023-05-02 23:26:37 -06:00
rodzic 55293e9ee6
commit 055aa6b39f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 0DEF1C662C9033F7
2 zmienionych plików z 15 dodań i 4 usunięć

Wyświetl plik

@ -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([]);

Wyświetl plik

@ -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 [];
}