X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FContact.php;h=18e041ab9849c1f18611f925b81e0e534deef8f1;hb=ea6f7aba40e4a99661d6fb4d4367e2762a27306e;hp=bc8a6cbe7bce8fdab50bbcdd7949ac845e1fb552;hpb=222333f64fcc3efc9c38de55455aa55e053ddccd;p=friendica.git diff --git a/src/Model/Contact.php b/src/Model/Contact.php index bc8a6cbe7b..18e041ab98 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -830,17 +830,17 @@ class Contact * Sends an unfriend message. Removes the contact for two-way unfriending or sharing only protocols (feed an mail) * * @param array $user User unfriending - * @param array $contact Contact unfriended + * @param array $contact Contact (uid != 0) unfriended * @param boolean $two_way Revoke eventual inbound follow as well * @return bool|null true if successful, false if not, null if no action was performed * @throws HTTPException\InternalServerErrorException * @throws \ImagickException */ - public static function terminateFriendship(array $user, array $contact, bool $two_way = false): bool + public static function terminateFriendship(array $user, array $contact): bool { - $result = Protocol::terminateFriendship($user, $contact, $two_way); + $result = Protocol::terminateFriendship($user, $contact); - if ($two_way || in_array($contact['network'], [Protocol::FEED, Protocol::MAIL])) { + if ($contact['rel'] == Contact::SHARING || in_array($contact['network'], [Protocol::FEED, Protocol::MAIL])) { self::remove($contact['id']); } else { self::update(['rel' => Contact::FOLLOWER], ['id' => $contact['id']]); @@ -872,7 +872,11 @@ class Contact // A null value here means the remote network doesn't support explicit follow revocation, we can still // break the locally recorded relationship if ($result !== false) { - DBA::update('contact', ['rel' => $contact['rel'] == self::FRIEND ? self::SHARING : self::NOTHING], ['id' => $contact['id']]); + if ($contact['rel'] == self::FRIEND) { + self::update(['rel' => self::SHARING], ['id' => $contact['id']]); + } else { + self::remove($contact['id']); + } } return $result; @@ -2701,7 +2705,7 @@ class Contact // Ensure to always have the correct network type, independent from the connection request method self::updateFromProbe($contact['id']); - Post\UserNotification::insertNotication($contact['id'], Verb::getID(Activity::FOLLOW), $importer['uid']); + Post\UserNotification::insertNotification($contact['id'], Verb::getID(Activity::FOLLOW), $importer['uid']); return true; } else { @@ -2732,7 +2736,7 @@ class Contact self::updateAvatar($contact_id, $photo, true); - Post\UserNotification::insertNotication($contact_id, Verb::getID(Activity::FOLLOW), $importer['uid']); + Post\UserNotification::insertNotification($contact_id, Verb::getID(Activity::FOLLOW), $importer['uid']); $contact_record = DBA::selectFirst('contact', ['id', 'network', 'name', 'url', 'photo'], ['id' => $contact_id]);