Skip to content

Commit

Permalink
Update ApiV1Controller and DiscoverController, fix postgres hashtag s…
Browse files Browse the repository at this point in the history
…earch
  • Loading branch information
dansup committed May 3, 2023
1 parent 55293e9 commit 055aa6b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
12 changes: 9 additions & 3 deletions app/Http/Controllers/Api/ApiV1Controller.php
Expand Up @@ -3245,9 +3245,15 @@ public function timelineHashtag(Request $request, $hashtag)
'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([]);
Expand Down
7 changes: 6 additions & 1 deletion app/Http/Controllers/DiscoverController.php
Expand Up @@ -61,7 +61,12 @@ public function getHashtags(Request $request)
$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 [];
}
Expand Down

0 comments on commit 055aa6b

Please sign in to comment.