Merge pull request #12801 from HankG/fix-mastodon-api-search

Fix mastodon api search
This commit is contained in:
Michael Vogel 2023-02-17 18:56:08 +01:00 committed by GitHub
commit 659fab0fe5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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')) {
$result['statuses'] = self::searchStatuses($uid, $request['q'], $request['account_id'], $request['max_id'], $request['min_id'], $limit, $request['offset']);
if (!is_array($result['statuses'])) {
@ -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);