]> git.mxchange.org Git - friendica.git/blobdiff - mod/follow.php
Force avatar update for Contact Advanced page
[friendica.git] / mod / follow.php
index 4f3acf5ef980bccb0edb88f2c4e632b2f6f5cb90..cdd7b4904e44f5845161aff1641bd7667d21778f 100644 (file)
@@ -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']);
                }
@@ -94,14 +97,14 @@ function follow_content(App $a)
 
        $protocol = Contact::getProtocol($ret['url'], $ret['network']);
 
-       if (($protocol == Protocol::DIASPORA) && !Config::get('system', 'diaspora_enabled')) {
+       if (($protocol == Protocol::DIASPORA) && !DI::config()->get('system', 'diaspora_enabled')) {
                notice(DI::l10n()->t("Diaspora support isn't enabled. Contact can't be added."));
                $submit = '';
                //$a->internalRedirect($_SESSION['return_path']);
                // NOTREACHED
        }
 
-       if (($protocol == Protocol::OSTATUS) && Config::get('system', 'ostatus_disabled')) {
+       if (($protocol == Protocol::OSTATUS) && DI::config()->get('system', 'ostatus_disabled')) {
                notice(DI::l10n()->t("OStatus support is disabled. Contact can't be added."));
                $submit = '';
                //$a->internalRedirect($_SESSION['return_path']);
@@ -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']);
@@ -186,7 +192,7 @@ function follow_content(App $a)
 
        $profiledata = Contact::getDetailsByURL($ret['url']);
        if ($profiledata) {
-               Profile::load($a, '', 0, $profiledata, false);
+               Profile::load($a, '', $profiledata, false);
        }
 
        if ($gcontact_id <> 0) {
@@ -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']);
+               }
+       }
+}