mirror of
https://github.com/friendica/friendica
synced 2025-04-26 19:10:11 +00:00
API: Account actions
This commit is contained in:
parent
5ade228c63
commit
45c2cc3887
13 changed files with 399 additions and 32 deletions
|
@ -2409,6 +2409,50 @@ class Contact
|
|||
return $contact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow a contact
|
||||
*
|
||||
* @param int $cid Public contact id
|
||||
* @param int $uid User ID
|
||||
*
|
||||
* @return bool "true" if following had been successful
|
||||
*/
|
||||
public static function follow(int $cid, int $uid)
|
||||
{
|
||||
$user = User::getById($uid);
|
||||
if (empty($user)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$contact = self::getById($cid, ['url']);
|
||||
|
||||
$result = self::createFromProbe($user, $contact['url'], false);
|
||||
|
||||
return $result['cid'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Unfollow a contact
|
||||
*
|
||||
* @param int $cid Public contact id
|
||||
* @param int $uid User ID
|
||||
*
|
||||
* @return bool "true" if unfollowing had been successful
|
||||
*/
|
||||
public static function unfollow(int $cid, int $uid)
|
||||
{
|
||||
$cdata = self::getPublicAndUserContacID($cid, $uid);
|
||||
if (empty($cdata['user'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$contact = self::getById($cdata['user']);
|
||||
|
||||
self::removeSharer([], $contact);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $importer Owner (local user) data
|
||||
* @param array $contact Existing owner-specific contact data we want to expand the relationship with. Optional.
|
||||
|
@ -2554,7 +2598,7 @@ class Contact
|
|||
return null;
|
||||
}
|
||||
|
||||
public static function removeFollower($importer, $contact, array $datarray = [], $item = "")
|
||||
public static function removeFollower($importer, $contact)
|
||||
{
|
||||
if (($contact['rel'] == self::FRIEND) || ($contact['rel'] == self::SHARING)) {
|
||||
DBA::update('contact', ['rel' => self::SHARING], ['id' => $contact['id']]);
|
||||
|
@ -2563,7 +2607,7 @@ class Contact
|
|||
}
|
||||
}
|
||||
|
||||
public static function removeSharer($importer, $contact, array $datarray = [], $item = "")
|
||||
public static function removeSharer($importer, $contact)
|
||||
{
|
||||
if (($contact['rel'] == self::FRIEND) || ($contact['rel'] == self::FOLLOWER)) {
|
||||
DBA::update('contact', ['rel' => self::FOLLOWER], ['id' => $contact['id']]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue