]> git.mxchange.org Git - friendica.git/commitdiff
Restore the behaviour to remove the remote contact upon termination
authorMichael <heluecht@pirati.ca>
Wed, 5 Sep 2018 05:02:06 +0000 (05:02 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 5 Sep 2018 05:02:06 +0000 (05:02 +0000)
mod/contacts.php
mod/dfrn_notify.php
mod/dirfind.php
mod/unfollow.php
src/Model/Contact.php
src/Protocol/DFRN.php
src/Worker/Notifier.php

index 70a582c6ee36b729111d652cc1c985049138238e..68f68fec3b94f10f97096bd524544acd9d0554d1 100644 (file)
@@ -368,7 +368,7 @@ function _contact_drop($orig_record)
                return;
        }
 
-       Contact::terminateFriendship($r[0], $orig_record);
+       Contact::terminateFriendship($r[0], $orig_record, true);
        Contact::remove($orig_record['id']);
 }
 
index 88f706385baa3d6f7878b816a42b4bf60d71eb3e..f653faca9599ade707593cf0de2df6c287f193ff 100644 (file)
@@ -322,8 +322,8 @@ function dfrn_notify_content(App $a) {
                $encrypted_id = '';
                $id_str       = $my_id . '.' . mt_rand(1000,9999);
 
-               $prv_key = trim($importer['prvkey']);
-               $pub_key = trim($importer['pubkey']);
+               $prv_key = trim($importer['cprvkey']);
+               $pub_key = trim($importer['cpubkey']);
                $dplx    = intval($importer['duplex']);
 
                if (($dplx && strlen($prv_key)) || (strlen($prv_key) && !strlen($pub_key))) {
index f4ddba45d4be253efade4b848c6b1b2048d43c19..332fe90f6c48cf5af9b0a170fb8e6783b2b2581a 100644 (file)
@@ -44,7 +44,7 @@ function dirfind_content(App $a, $prefix = "") {
 
        $local = Config::get('system','poco_local_search');
 
-       $search = $prefix.notags(trim($_REQUEST['search']));
+       $search = $prefix.notags(trim(defaults($_REQUEST, 'search', '')));
 
        $header = '';
 
index 956b6fbdb73a7277f7c7745805b7bb12fd5b701c..0aa114759f605e7c0dd4f9a82047c1ab89ba5b7d 100644 (file)
@@ -46,13 +46,15 @@ function unfollow_post()
                // NOTREACHED
        }
 
+       $dissolve = ($contact['rel'] == Contact::SHARING);
+
        $owner = User::getOwnerDataById($uid);
        if ($owner) {
-               Contact::terminateFriendship($owner, $contact);
+               Contact::terminateFriendship($owner, $contact, $dissolve);
        }
 
        // Sharing-only contacts get deleted as there no relationship any more
-       if ($contact['rel'] == Contact::SHARING) {
+       if ($dissolve) {
                Contact::remove($contact['id']);
                $return_path = 'contacts';
        } else {
index d53126f6ff2aed90db3f1eda8c393f79f205a79b..1bbc0228a806a46dc7729ef1a852e7d12d53cb81 100644 (file)
@@ -17,6 +17,7 @@ use Friendica\Model\Profile;
 use Friendica\Network\Probe;
 use Friendica\Object\Image;
 use Friendica\Protocol\Diaspora;
+use Friendica\Protocol\DFRN;
 use Friendica\Protocol\OStatus;
 use Friendica\Protocol\PortableContact;
 use Friendica\Protocol\Salmon;
@@ -528,13 +529,16 @@ class Contact extends BaseObject
        /**
         * @brief Sends an unfriend message. Does not remove the contact
         *
-        * @param array $user    User unfriending
-        * @param array $contact Contact unfriended
+        * @param array   $user     User unfriending
+        * @param array   $contact  Contact unfriended
+        * @param boolean $dissolve Remove the contact on the remote side
         * @return void
         */
-       public static function terminateFriendship(array $user, array $contact)
+       public static function terminateFriendship(array $user, array $contact, $dissolve = false)
        {
-               if (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DFRN])) {
+               if (($contact['network'] == Protocol::DFRN) && $dissolve) {
+                       DFRN::deliver($user, $contact, 'placeholder', true);
+               } elseif (in_array($contact['network'], [Protocol::OSTATUS, Protocol::DFRN])) {
                        // create an unfollow slap
                        $item = [];
                        $item['verb'] = NAMESPACE_OSTATUS . "/unfollow";
index c4355503137923dc9c662f38e626b040b2be20c3..b207c3ca87cde7b4be9d705e936150c26a2c4cac 100644 (file)
@@ -81,7 +81,8 @@ class DFRN
                                return [];
                        }
 
-                       $user['importer_uid']  = $user['uid'];
+                       $user['importer_uid'] = $user['uid'];
+                       $user['uprvkey'] = $user['prvkey'];
                } else {
                        $user = ['importer_uid' => 0, 'uprvkey' => '', 'timezone' => 'UTC',
                                'nickname' => '', 'sprvkey' => '', 'spubkey' => '',
@@ -1168,10 +1169,12 @@ class DFRN
                $a = get_app();
 
                // At first try the Diaspora transport layer
-               $ret = self::transmit($owner, $contact, $atom);
-               if ($ret >= 200) {
-                       logger('Delivery via Diaspora transport layer was successful with status ' . $ret);
-                       return $ret;
+               if (!$dissolve) {
+                       $ret = self::transmit($owner, $contact, $atom);
+                       if ($ret >= 200) {
+                               logger('Delivery via Diaspora transport layer was successful with status ' . $ret);
+                               return $ret;
+                       }
                }
 
                $idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']);
index 6d2733b8ee2153671a43ce872fa32aadfb25e4a3..61eaba388b2d365a58829bcf4abddcb1bda54874 100644 (file)
@@ -96,7 +96,7 @@ class Notifier
                                return;
                        }
                        foreach ($r as $contact) {
-                               Contact::terminateFriendship($user, $contact);
+                               Contact::terminateFriendship($user, $contact, true);
                        }
                        return;
                } elseif ($cmd == Delivery::RELOCATION) {