Move auto-follow/unfollow after the checks

This commit is contained in:
Michael 2020-10-20 04:05:04 +00:00
parent 33575a94fa
commit c6a23f1272
2 changed files with 16 additions and 14 deletions

View 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

View 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),