<?php
/**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
$this->appMode = $appMode;
}
- protected function doExecute()
+ protected function doExecute(): int
{
if ($this->getOption('v')) {
$this->out('Class: ' . __CLASS__);
$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');
}
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');
}
}