]> git.mxchange.org Git - friendica.git/commitdiff
Enable unfollowing contacts from all networks (but Statusnet)
authorHypolite Petovan <mrpetovan@gmail.com>
Thu, 30 Aug 2018 12:52:15 +0000 (08:52 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Thu, 30 Aug 2018 12:52:15 +0000 (08:52 -0400)
mod/contacts.php
mod/unfollow.php

index 4e8769717212eaa81dc03b2151803ac09f7ce017..38896a611a3c7d08f88a480bf2d31dd36665534a 100644 (file)
@@ -595,7 +595,7 @@ function contacts_content(App $a, $update = 0)
                /// @todo Only show the following link with DFRN when the remote version supports it
                $follow = '';
                $follow_text = '';
-               if (in_array($contact['network'], [Protocol::DIASPORA, Protocol::OSTATUS, Protocol::DFRN])) {
+               if ($contact['network'] != Protocol::STATUSNET) {
                        if (in_array($contact['rel'], [Contact::FRIEND, Contact::SHARING])) {
                                $follow = System::baseUrl(true) . "/unfollow?url=" . urlencode($contact["url"]);
                                $follow_text = L10n::t("Disconnect/Unfollow");
index 5942171247a86f29c6698d5df78b7b34080b2132..4bc64e4fc30be2f73062ba1958c24b7d60afec8c 100644 (file)
@@ -28,13 +28,20 @@ function unfollow_post(App $a)
        $return_url = $_SESSION['return_url'];
 
        $condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
-                       $uid, Contact::SHARING, Contact::FRIEND, normalise_link($url),
-                       normalise_link($url), $url, Protocol::STATUSNET];
+               $uid, Contact::SHARING, Contact::FRIEND, normalise_link($url),
+               normalise_link($url), $url];
        $contact = DBA::selectFirst('contact', [], $condition);
 
        if (!DBA::isResult($contact)) {
-               notice(L10n::t("Contact wasn't found or can't be unfollowed."));
+               notice(L10n::t("You aren't following this contact."));
                goaway($return_url);
+               // NOTREACHED
+       }
+
+       if ($contact['network'] == Protocol::STATUSNET) {
+               notice(L10n::t('Unfollowing is currently not supported by your network.'));
+               goaway($return_url);
+               // NOTREACHED
        }
 
        if (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DIASPORA, Protocol::DFRN])) {
@@ -74,21 +81,21 @@ function unfollow_content(App $a)
 
        $submit = L10n::t('Submit Request');
 
-       $condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
-                       local_user(), Contact::SHARING, Contact::FRIEND, normalise_link($url),
-                       normalise_link($url), $url, Protocol::STATUSNET];
+       $condition = ["`uid` = ? AND (`rel` = ? OR `rel` = ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?)",
+               local_user(), Contact::SHARING, Contact::FRIEND, normalise_link($url),
+               normalise_link($url), $url];
 
        $contact = DBA::selectFirst('contact', ['url', 'network', 'addr', 'name'], $condition);
 
        if (!DBA::isResult($contact)) {
-               notice(L10n::t("You aren't a friend of this contact.").EOL);
-               $submit = "";
+               notice(L10n::t("You aren't following this contact."));
+               goaway('contacts');
                // NOTREACHED
        }
 
-       if (!in_array($contact['network'], [Protocol::DIASPORA, Protocol::OSTATUS, Protocol::DFRN])) {
-               notice(L10n::t("Unfollowing is currently not supported by your network.").EOL);
-               $submit = "";
+       if ($contact['network'] == Protocol::STATUSNET) {
+               notice(L10n::t('Unfollowing is currently not supported by your network.'));
+               goaway('contacts/' . $contact['id']);
                // NOTREACHED
        }