]> git.mxchange.org Git - friendica.git/blobdiff - src/Console/Contact.php
Convert class calls into DI calls
[friendica.git] / src / Console / Contact.php
index cbfd4b6c6dc032a727de00f333ace9da994bec99..f051d870a295c8710a72f21a7b7c57992fc3f486 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -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);
        }
 
        /**