]> git.mxchange.org Git - friendica.git/blobdiff - src/Console/Contact.php
Move server domain pattern blocklist features to its own class
[friendica.git] / src / Console / Contact.php
index 11f7f87ced01f35045b1803d7061d826e34981e8..37f3f056e4f755da410df6b52419f702c53ef090 100644 (file)
@@ -76,7 +76,7 @@ HELP;
                $this->appMode = $appMode;
        }
 
-       protected function doExecute()
+       protected function doExecute(): int
        {
                if ($this->getOption('v')) {
                        $this->out('Class: ' . __CLASS__);
@@ -199,19 +199,18 @@ 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 === 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');
                }
        }