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;
$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']);
}
}
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']);
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']);
+ }
+ }
+}