From c084e6a4271a9e1160d6e5079dd13da1c8965b6a Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Wed, 15 Feb 2023 15:12:58 -0500 Subject: [PATCH 1/3] Allows @ in query on statuses when resolving since Mastodon links have it --- src/Module/Api/Mastodon/Search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Module/Api/Mastodon/Search.php b/src/Module/Api/Mastodon/Search.php index 07d1daa19e..0306777117 100644 --- a/src/Module/Api/Mastodon/Search.php +++ b/src/Module/Api/Mastodon/Search.php @@ -77,7 +77,7 @@ class Search extends BaseApi } } - if ((empty($request['type']) || ($request['type'] == 'statuses')) && (strpos($request['q'], '@') == false)) { + if ((empty($request['type']) || ($request['type'] == 'statuses')) && (!strpos($request['q'], '@') || $request['resolve'])) { $result['statuses'] = self::searchStatuses($uid, $request['q'], $request['account_id'], $request['max_id'], $request['min_id'], $limit, $request['offset']); if (!is_array($result['statuses'])) { From cb1adf983b2fc96bea763788b51036486c95bdaa Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Wed, 15 Feb 2023 15:13:30 -0500 Subject: [PATCH 2/3] Fix style error --- src/Module/Api/Mastodon/Search.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Module/Api/Mastodon/Search.php b/src/Module/Api/Mastodon/Search.php index 0306777117..96d41c3b2e 100644 --- a/src/Module/Api/Mastodon/Search.php +++ b/src/Module/Api/Mastodon/Search.php @@ -108,8 +108,7 @@ class Search extends BaseApi */ private static function searchAccounts(int $uid, string $q, bool $resolve, int $limit, int $offset, bool $following) { - if ( - ($offset == 0) && (strrpos($q, '@') > 0 || Network::isValidHttpUrl($q)) + if (($offset == 0) && (strrpos($q, '@') > 0 || Network::isValidHttpUrl($q)) && $id = Contact::getIdForURL($q, 0, $resolve ? null : false) ) { return DI::mstdnAccount()->createFromContactId($id, $uid); From 67b8ad242b7afd54f8ea3e3eb59cf868a9810f71 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Fri, 17 Feb 2023 10:49:32 -0500 Subject: [PATCH 3/3] Allow @-symbols in Mastodon status searches under all conditions --- src/Module/Api/Mastodon/Search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Module/Api/Mastodon/Search.php b/src/Module/Api/Mastodon/Search.php index 96d41c3b2e..c35e33062b 100644 --- a/src/Module/Api/Mastodon/Search.php +++ b/src/Module/Api/Mastodon/Search.php @@ -77,7 +77,7 @@ class Search extends BaseApi } } - if ((empty($request['type']) || ($request['type'] == 'statuses')) && (!strpos($request['q'], '@') || $request['resolve'])) { + if (empty($request['type']) || ($request['type'] == 'statuses')) { $result['statuses'] = self::searchStatuses($uid, $request['q'], $request['account_id'], $request['max_id'], $request['min_id'], $limit, $request['offset']); if (!is_array($result['statuses'])) {