X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FConsole%2FContact.php;h=11f7f87ced01f35045b1803d7061d826e34981e8;hb=4c39faca95e6f8510c9ee9cbf7957855bc718ec7;hp=a64ae660c3df64dcfddb7951d12b661500e9bd9d;hpb=05481cab3dfef51418926f9822b161db3e84fc55;p=friendica.git diff --git a/src/Console/Contact.php b/src/Console/Contact.php index a64ae660c3..11f7f87ced 100644 --- a/src/Console/Contact.php +++ b/src/Console/Contact.php @@ -1,6 +1,6 @@ getArgument(3); - if (empty($network) && $network !== '') { + if ($network === null) { $this->out('Enter network, or leave blank: '); $network = CliPrompt::prompt(); } - $result = ContactModel::createFromProbe($user, $url, false, $network); + $result = ContactModel::createFromProbeForUser($user['uid'], $url, $network); if ($result['success']) { $this->out('User ' . $user['nickname'] . ' now connected to ' . $url . ', contact ID ' . $result['cid']); @@ -174,11 +178,12 @@ HELP; } /** - * Sends an unfriend message. Does not remove the contact + * Sends an unfriend message. * * @return bool True, if the command was successful + * @throws \Exception */ - private function terminateContact() + private function terminateContact(): bool { $cid = $this->getArgument(1); if (empty($cid)) { @@ -196,13 +201,23 @@ HELP; $user = UserModel::getById($contact['uid']); - $result = ContactModel::terminateFriendship($user, $contact); + try { + $result = ContactModel::terminateFriendship($user, $contact); + if ($result === false) { + throw new RuntimeException('Unable to unfollow this contact, please retry in a few minutes or check the logs.'); + } + + $this->out('Contact was successfully unfollowed'); + + return true; + } catch (\Exception $e) { + DI::logger()->error($e->getMessage(), ['owner' => $user, '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() { @@ -215,7 +230,7 @@ HELP; } } - $result = ContactModel::remove($cid); + ContactModel::remove($cid); } /** @@ -268,8 +283,8 @@ HELP; } break; case 'url': - $user = $this->getUserByNick(2); - $url = $this->getArgument(3); + $user = $this->getUserByNick(2); + $url = $this->getArgument(3); $contact = ContactModel::getByURLForUser($url, $user['uid'], false, $fields); if (!empty($contact)) { $addRow($contact);