+ * 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 (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
+ {
+ $result = Protocol::terminateFriendship($user, $contact);
+
+ 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']]);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Revoke follow privileges of the remote user contact