Browse Source

Merge pull request #4222 from pixelfed/staging

Staging
daniel 2 years ago
parent
commit
af5bc07557
2 changed files with 8 additions and 3 deletions
  1. 1 0
      CHANGELOG.md
  2. 7 3
      app/Services/SearchApiV2Service.php

+ 1 - 0
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)

+ 7 - 3
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()