API: Account actions

This commit is contained in:
Michael 2021-05-14 21:51:32 +00:00
parent 5ade228c63
commit 45c2cc3887
13 changed files with 399 additions and 32 deletions

View file

@ -44,9 +44,9 @@ class Account extends BaseFactory
{
parent::__construct($logger);
$this->baseUrl = $baseURL;
$this->baseUrl = $baseURL;
$this->profileField = $profileField;
$this->mstdnField = $mstdnField;
$this->mstdnField = $mstdnField;
}
/**
@ -61,7 +61,7 @@ class Account extends BaseFactory
$cdata = Contact::getPublicAndUserContacID($contactId, $uid);
if (!empty($cdata)) {
$publicContact = Contact::getById($cdata['public']);
$userContact = Contact::getById($cdata['user']);
$userContact = Contact::getById($cdata['user']);
} else {
$publicContact = Contact::getById($contactId);
$userContact = [];

View file

@ -37,13 +37,33 @@ class Relationship extends BaseFactory
return $this->createFromContact(Contact::getById($userContactId));
}
/**
* @param int $publicContactId Contact row id with uid = 0
* @param int $uid User ID
* @return RelationshipEntity
* @throws \Exception
*/
public function createFromPublicContactId(int $publicContactId, int $uid)
{
$cdata = Contact::getPublicAndUserContacID($publicContactId, $uid);
if (!empty($cdata)) {
$cid = $cdata['user'];
} else {
$cid = $publicContactId;
}
return $this->createFromContact(Contact::getById($cid));
}
/**
* @param array $userContact Full contact row record with uid != 0
* @return RelationshipEntity
*/
public function createFromContact(array $userContact)
{
return new RelationshipEntity($userContact['id'], $userContact);
return new RelationshipEntity($userContact['id'], $userContact,
Contact\User::isBlocked($userContact['id'], $userContact['uid']),
Contact\User::isIgnored($userContact['id'], $userContact['uid']));
}
/**