]> git.mxchange.org Git - friendica.git/blobdiff - mod/unfollow.php
Merge pull request #10173 from annando/attach-speed
[friendica.git] / mod / unfollow.php
index d24745c8bb5efa584ad24999d40c541f08e7d593..1c6022a4cb4b31dce2420f33d078dd96a004cb65 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
  *
@@ -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']));
 
@@ -61,7 +59,7 @@ function unfollow_content(App $a)
                local_user(), Contact::SHARING, Contact::FRIEND, Strings::normaliseLink($url),
                Strings::normaliseLink($url), $url];
 
-       $contact = DBA::selectFirst('contact', ['url', 'network', 'addr', 'name'], $condition);
+       $contact = DBA::selectFirst('contact', ['url', 'id', 'uid', 'network', 'addr', 'name'], $condition);
 
        if (!DBA::isResult($contact)) {
                notice(DI::l10n()->t("You aren't following this contact."));
@@ -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'     => '',
@@ -97,7 +99,7 @@ function unfollow_content(App $a)
                '$submit'        => DI::l10n()->t('Submit Request'),
                '$cancel'        => DI::l10n()->t('Cancel'),
                '$url'           => $contact['url'],
-               '$zrl'           => Contact::magicLink($contact['url']),
+               '$zrl'           => Contact::magicLinkByContact($contact),
                '$url_label'     => DI::l10n()->t('Profile URL'),
                '$myaddr'        => $self['url'],
                '$request'       => $request,
@@ -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),