X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FConsole%2FContact.php;h=a80b88349a157bc99bfca55bbc720be1fbb74061;hb=1523fa22369fd73b5d7d5e50269f871917d7613c;hp=cbfd4b6c6dc032a727de00f333ace9da994bec99;hpb=a44d200c211eff891f7d275b7e54ded33a50c446;p=friendica.git diff --git a/src/Console/Contact.php b/src/Console/Contact.php index cbfd4b6c6d..a80b88349a 100644 --- a/src/Console/Contact.php +++ b/src/Console/Contact.php @@ -1,6 +1,6 @@ appMode = $appMode; } - protected function doExecute() + protected function doExecute(): int { if ($this->getOption('v')) { $this->out('Class: ' . __CLASS__); @@ -157,7 +157,7 @@ HELP; $url = Probe::cleanURI($url); - $contact = ContactModel::getByURLForUser($url, $user['uid']); + $contact = ContactModel::getByURL($url, null, [], $user['uid']); if (!empty($contact)) { throw new RuntimeException('Contact already exists'); } @@ -199,31 +199,24 @@ HELP; throw new RuntimeException('Contact not found'); } - $user = UserModel::getById($contact['uid']); + if (empty($contact['uid'])) { + throw new RuntimeException('Contact must be user-specific (uid != 0)'); + } try { - $result = ContactModel::terminateFriendship($user, $contact); - if ($result === null) { - throw new RuntimeException('Unfollowing is currently not supported by this contact\'s network.'); - } - - if ($result === false) { - throw new RuntimeException('Unable to unfollow this contact, please retry in a few minutes or check the logs.'); - } + ContactModel::unfollow($contact); $this->out('Contact was successfully unfollowed'); return true; } catch (\Exception $e) { - DI::logger()->error($e->getMessage(), ['owner' => $user, 'contact' => $contact]); + DI::logger()->error($e->getMessage(), ['contact' => $contact]); throw new RuntimeException('Unable to unfollow this contact, please check the log'); } } /** * Marks a contact for removal - * - * @return bool True, if the command was successful */ private function removeContact() { @@ -236,7 +229,7 @@ HELP; } } - $result = ContactModel::remove($cid); + ContactModel::remove($cid); } /**