]> git.mxchange.org Git - friendica.git/blobdiff - mod/follow.php
Merge pull request #10300 from annando/issue-10264
[friendica.git] / mod / follow.php
index 4f0c3fc6fe4543ed66f40c2483ec93999df9df3f..ed8e3aa5fee881bd470d308be901fa3adb613809 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -28,6 +28,7 @@ use Friendica\Model\Profile;
 use Friendica\Model\Item;
 use Friendica\Network\Probe;
 use Friendica\Database\DBA;
+use Friendica\Model\Post;
 use Friendica\Model\User;
 use Friendica\Util\Strings;
 
@@ -41,7 +42,9 @@ function follow_post(App $a)
                DI::baseUrl()->redirect('contact');
        }
 
-       follow_process($a);
+       $url = Probe::cleanURI($_REQUEST['url']);
+
+       follow_process($a, $url);
 }
 
 function follow_content(App $a)
@@ -68,10 +71,6 @@ function follow_content(App $a)
                DI::baseUrl()->redirect($return_path);
        }
 
-       if (!empty($_REQUEST['auto'])) {
-               follow_process($a);
-       }
-
        $submit = DI::l10n()->t('Submit Request');
 
        // Don't try to add a pending contact
@@ -123,6 +122,10 @@ function follow_content(App $a)
                $request = $contact['request'];
                $tpl = Renderer::getMarkupTemplate('dfrn_request.tpl');
        } else {
+               if (!empty($_REQUEST['auto'])) {
+                       follow_process($a, $contact['url']);
+               }
+       
                $request = DI::baseUrl() . '/follow';
                $tpl = Renderer::getMarkupTemplate('auto_request.tpl');
        }
@@ -175,9 +178,8 @@ function follow_content(App $a)
        return $o;
 }
 
-function follow_process(App $a)
+function follow_process(App $a, string $url)
 {
-       $url = Probe::cleanURI($_REQUEST['url']);
        $return_path = 'follow?url=' . urlencode($url);
 
        // Makes the connection request for friendica contacts easier
@@ -212,7 +214,7 @@ function follow_remote_item($url)
        }
 
        if (!empty($item_id)) {
-               $item = Item::selectFirst(['guid'], ['id' => $item_id]);
+               $item = Post::selectFirst(['guid'], ['id' => $item_id]);
                if (DBA::isResult($item)) {
                        DI::baseUrl()->redirect('display/' . $item['guid']);
                }