]> git.mxchange.org Git - friendica.git/commitdiff
Move auto-follow/unfollow after the checks
authorMichael <heluecht@pirati.ca>
Tue, 20 Oct 2020 04:05:04 +0000 (04:05 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 20 Oct 2020 04:05:04 +0000 (04:05 +0000)
mod/follow.php
mod/unfollow.php

index 4f0c3fc6fe4543ed66f40c2483ec93999df9df3f..d47cec76de735472f9f6e66dc3353d17066c889c 100644 (file)
@@ -41,7 +41,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 +70,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
@@ -139,6 +137,10 @@ function follow_content(App $a)
        // Makes the connection request for friendica contacts easier
        $_SESSION['fastlane'] = $contact['url'];
 
+       if (!empty($_REQUEST['auto'])) {
+               follow_process($a, $contact['url']);
+       }
+
        $o = Renderer::replaceMacros($tpl, [
                '$header'        => DI::l10n()->t('Connect/Follow'),
                '$pls_answer'    => DI::l10n()->t('Please answer the following:'),
@@ -175,9 +177,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
index d24745c8bb5efa584ad24999d40c541f08e7d593..54e015cf5272a25f1de02672ca1475c76140cf37 100644 (file)
@@ -37,7 +37,9 @@ function unfollow_post(App $a)
                // NOTREACHED
        }
 
-       unfollow_process();
+       $url = Strings::escapeTags(trim($_REQUEST['url'] ?? ''));
+
+       unfollow_process($url);
 }
 
 function unfollow_content(App $a)
@@ -50,10 +52,6 @@ function unfollow_content(App $a)
                // NOTREACHED
        }
 
-       if (!empty($_REQUEST['auto'])) {
-               unfollow_process();
-       }
-
        $uid = local_user();
        $url = Strings::escapeTags(trim($_REQUEST['url']));
 
@@ -89,6 +87,10 @@ function unfollow_content(App $a)
        // Makes the connection request for friendica contacts easier
        $_SESSION['fastlane'] = $contact['url'];
 
+       if (!empty($_REQUEST['auto'])) {
+               unfollow_process($contact['url']);
+       }
+
        $o = Renderer::replaceMacros($tpl, [
                '$header'        => DI::l10n()->t('Disconnect/Unfollow'),
                '$page_desc'     => '',
@@ -116,12 +118,11 @@ function unfollow_content(App $a)
        return $o;
 }
 
-function unfollow_process()
+function unfollow_process(string $url)
 {
        $base_return_path = 'contact';
 
        $uid = local_user();
-       $url = Strings::escapeTags(trim($_REQUEST['url'] ?? ''));
 
        $condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)",
                $uid, Contact::SHARING, Contact::FRIEND, Strings::normaliseLink($url),