From 1992b5bc90425af566e0be451343e23689e2f5a4 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 4 Mar 2023 14:36:17 -0700 Subject: [PATCH 1/2] Update SearchApiV2Service, fix hashtag search. --- app/Services/SearchApiV2Service.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Services/SearchApiV2Service.php b/app/Services/SearchApiV2Service.php index f5703c7e5..64c8303e7 100644 --- a/app/Services/SearchApiV2Service.php +++ b/app/Services/SearchApiV2Service.php @@ -122,11 +122,15 @@ class SearchApiV2Service protected function hashtags() { $mastodonMode = self::$mastodonMode; + $q = $this->query->input('q'); $limit = $this->query->input('limit') ?? 20; $offset = $this->query->input('offset') ?? 0; - $query = $this->query->input('q') . '%'; - return Hashtag::where('can_search', true) - ->where('name', 'like', $query) + $query = Str::startsWith($q, '#') ? substr($q, 1) . '%' : $q . '%'; + return Hashtag::where('name', 'like', $query) + ->where(function($q) { + return $q->where('can_search', true) + ->orWhereNull('can_search'); + }) ->offset($offset) ->limit($limit) ->get() From a6d37e89d2a10f9e5f122ac4332ee9e44c300ed5 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 4 Mar 2023 14:37:16 -0700 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb48a315b..8f99bfb6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -116,6 +116,7 @@ - Update mute/block logic with admin defined limits and improved filtering to skip deleted accounts ([5b879f01](https://github.com/pixelfed/pixelfed/commit/5b879f01)) - Update FollowPipeline, fix followers_count and following_count counters ([6153b620](https://github.com/pixelfed/pixelfed/commit/6153b620)) - Update ApiV1Controller, fix media update. Fixes #4196 ([f3164650](https://github.com/pixelfed/pixelfed/commit/f3164650)) +- Update SearchApiV2Service, fix hashtag search. ([1992b5bc](https://github.com/pixelfed/pixelfed/commit/1992b5bc)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.4 (2022-10-04)](https://github.com/pixelfed/pixelfed/compare/v0.11.3...v0.11.4)