From c6a23f1272eab3b5e610499886511956225610bd Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 20 Oct 2020 04:05:04 +0000 Subject: [PATCH] Move auto-follow/unfollow after the checks --- mod/follow.php | 15 ++++++++------- mod/unfollow.php | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/mod/follow.php b/mod/follow.php index 4f0c3fc6fe..d47cec76de 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -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 diff --git a/mod/unfollow.php b/mod/unfollow.php index d24745c8bb..54e015cf52 100644 --- a/mod/unfollow.php +++ b/mod/unfollow.php @@ -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),