Fix follow/unfollow

This commit is contained in:
Michael 2024-07-31 04:37:17 +00:00
parent 26f8392754
commit 534db0d09a
23 changed files with 236 additions and 90 deletions

View file

@ -412,6 +412,29 @@ class User
return 0;
}
/**
* Returns the user id of a given contact id
*
* @param int $cid
*
* @return integer user id
* @throws Exception
*/
public static function getIdForContactId(int $cid): int
{
$account = Contact::selectFirstAccountUser(['pid', 'self', 'uid'], ['id' => $cid]);
if (empty($account['pid'])) {
return 0;
}
if ($account['self']) {
return $account['uid'];
}
$self = Contact::selectFirstAccountUser(['uid'], ['pid' => $cid, 'self' => true]);
return $self['uid'] ?? 0;
}
/**
* Get a user based on its email
*