Change static methods to dynamic in Mastodon Search class

This commit is contained in:
Art4 2025-01-13 12:07:05 +00:00
parent 33b5ba35d4
commit c335754dec

View file

@ -53,7 +53,7 @@ class Search extends BaseApi
$result = ['accounts' => [], 'statuses' => [], 'hashtags' => []];
if (empty($request['type']) || ($request['type'] == 'accounts')) {
$result['accounts'] = self::searchAccounts($uid, $request['q'], $request['resolve'], $limit, $request['offset'], $request['following']);
$result['accounts'] = $this->searchAccounts($uid, $request['q'], $request['resolve'], $limit, $request['offset'], $request['following']);
if (!is_array($result['accounts'])) {
// Curbing the search if we got an exact result
@ -63,7 +63,7 @@ class Search extends BaseApi
}
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']);
$result['statuses'] = $this->searchStatuses($uid, $request['q'], $request['account_id'], $request['max_id'], $request['min_id'], $limit, $request['offset']);
if (!is_array($result['statuses'])) {
// Curbing the search if we got an exact result
@ -73,7 +73,7 @@ class Search extends BaseApi
}
if ((empty($request['type']) || ($request['type'] == 'hashtags')) && (strpos($request['q'], '@') == false)) {
$result['hashtags'] = self::searchHashtags($request['q'], $request['exclude_unreviewed'], $limit, $request['offset'], $this->parameters['version']);
$result['hashtags'] = $this->searchHashtags($request['q'], $request['exclude_unreviewed'], $limit, $request['offset'], $this->parameters['version']);
}
$this->jsonExit($result);
@ -91,7 +91,7 @@ class Search extends BaseApi
* @throws \Friendica\Network\HTTPException\NotFoundException
* @throws \ImagickException
*/
private static function searchAccounts(int $uid, string $q, bool $resolve, int $limit, int $offset, bool $following)
private function searchAccounts(int $uid, string $q, bool $resolve, int $limit, int $offset, bool $following)
{
if (($offset == 0) && (strrpos($q, '@') > 0 || Network::isValidHttpUrl($q))
&& $id = Contact::getIdForURL($q, 0, $resolve ? null : false)
@ -120,7 +120,7 @@ class Search extends BaseApi
* @throws \Friendica\Network\HTTPException\NotFoundException
* @throws \ImagickException
*/
private static function searchStatuses(int $uid, string $q, string $account_id, int $max_id, int $min_id, int $limit, int $offset)
private function searchStatuses(int $uid, string $q, string $account_id, int $max_id, int $min_id, int $limit, int $offset)
{
if (Network::isValidHttpUrl($q)) {
// Unique post search, any offset greater than 0 should return empty result
@ -185,7 +185,7 @@ class Search extends BaseApi
return $statuses;
}
private static function searchHashtags(string $q, bool $exclude_unreviewed, int $limit, int $offset, int $version): array
private function searchHashtags(string $q, bool $exclude_unreviewed, int $limit, int $offset, int $version): array
{
$q = ltrim($q, '#');