X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Ffollow.php;h=5ab3d3526419c073a2d2020468f5bd8c4d635f37;hb=d1be68b75462df77100c9262134b70717635ddfe;hp=276a389e837b4c1f8f7833a65601a72afd0e1f36;hpb=6c36fd9e01510a14fea9de766b4afe6760912a2e;p=friendica.git diff --git a/mod/follow.php b/mod/follow.php index 276a389e83..5ab3d35264 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -3,12 +3,12 @@ * @file mod/follow.php */ use Friendica\App; -use Friendica\Core\Config; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Profile; +use Friendica\Model\Item; use Friendica\Network\Probe; use Friendica\Database\DBA; use Friendica\Util\Strings; @@ -34,6 +34,9 @@ function follow_post(App $a) $result = Contact::createFromProbe($uid, $url, true); if ($result['success'] == false) { + // Possibly it is a remote item and not an account + follow_remote_item($url); + if ($result['message']) { notice($result['message']); } @@ -109,6 +112,9 @@ function follow_content(App $a) } if ($protocol == Protocol::PHANTOM) { + // Possibly it is a remote item and not an account + follow_remote_item($url); + notice(DI::l10n()->t("The network type couldn't be detected. Contact can't be added.")); $submit = ''; //$a->internalRedirect($_SESSION['return_path']); @@ -200,3 +206,19 @@ function follow_content(App $a) return $o; } + +function follow_remote_item($url) +{ + $item_id = Item::fetchByLink($url, local_user()); + if (!$item_id) { + // If the user-specific search failed, we search and probe a public post + $item_id = Item::fetchByLink($url); + } + + if (!empty($item_id)) { + $item = Item::selectFirst(['guid'], ['id' => $item_id]); + if (DBA::isResult($item)) { + DI::baseUrl()->redirect('display/' . $item['guid']); + } + } +}