mirror of
https://github.com/friendica/friendica
synced 2024-11-14 07:02:53 +00:00
Rename Api\Mastodon\Account::create contact parameter to publicContact
- Update Mastodon entity documentation link - Add default value for fields
This commit is contained in:
parent
6f199ab7b3
commit
9ed8479b32
1 changed files with 17 additions and 15 deletions
|
@ -10,7 +10,7 @@ use Friendica\Util\DateTimeFormat;
|
||||||
/**
|
/**
|
||||||
* Class Account
|
* Class Account
|
||||||
*
|
*
|
||||||
* @see https://docs.joinmastodon.org/api/entities/#account
|
* @see https://docs.joinmastodon.org/entities/account
|
||||||
*/
|
*/
|
||||||
class Account
|
class Account
|
||||||
{
|
{
|
||||||
|
@ -54,35 +54,37 @@ class Account
|
||||||
var $bot = null;
|
var $bot = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an account record from a contact record. Expects all contact table fields to be set
|
* Creates an account record from a public contact record. Expects all contact table fields to be set.
|
||||||
*
|
*
|
||||||
* @param array $contact Full contact table record
|
* @param array $publicContact Full contact table record with uid = 0
|
||||||
* @param array $apcontact Full apcontact table record
|
* @param array $apcontact Optional full apcontact table record
|
||||||
* @return Account
|
* @return Account
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function createFromContact(array $contact, array $apcontact = [])
|
public static function createFromContact(array $publicContact, array $apcontact = [])
|
||||||
{
|
{
|
||||||
$account = new Account();
|
$account = new Account();
|
||||||
$account->id = $contact['id'];
|
$account->id = $publicContact['id'];
|
||||||
$account->username = $contact['nick'];
|
$account->username = $publicContact['nick'];
|
||||||
$account->acct = $contact['nick'];
|
$account->acct = $publicContact['addr'];
|
||||||
$account->display_name = $contact['name'];
|
$account->display_name = $publicContact['name'];
|
||||||
$account->locked = !empty($apcontact['manually-approve']);
|
$account->locked = !empty($apcontact['manually-approve']);
|
||||||
$account->created_at = DateTimeFormat::utc($contact['created'], DateTimeFormat::ATOM);
|
$account->created_at = DateTimeFormat::utc($publicContact['created'], DateTimeFormat::ATOM);
|
||||||
$account->followers_count = $apcontact['followers_count'] ?? 0;
|
$account->followers_count = $apcontact['followers_count'] ?? 0;
|
||||||
$account->following_count = $apcontact['following_count'] ?? 0;
|
$account->following_count = $apcontact['following_count'] ?? 0;
|
||||||
$account->statuses_count = $apcontact['statuses_count'] ?? 0;
|
$account->statuses_count = $apcontact['statuses_count'] ?? 0;
|
||||||
$account->note = BBCode::convert($contact['about'], false);
|
$account->note = BBCode::convert($publicContact['about'], false);
|
||||||
$account->url = $contact['url'];
|
$account->url = $publicContact['url'];
|
||||||
$account->avatar = $contact['avatar'];
|
$account->avatar = $publicContact['avatar'];
|
||||||
$account->avatar_static = $contact['avatar'];
|
$account->avatar_static = $publicContact['avatar'];
|
||||||
// No header picture in Friendica
|
// No header picture in Friendica
|
||||||
$account->header = '';
|
$account->header = '';
|
||||||
$account->header_static = '';
|
$account->header_static = '';
|
||||||
// No custom emojis per account in Friendica
|
// No custom emojis per account in Friendica
|
||||||
$account->emojis = [];
|
$account->emojis = [];
|
||||||
$account->bot = ($contact['contact-type'] == Contact::TYPE_NEWS);
|
// No metadata fields in Friendica
|
||||||
|
$account->fields = [];
|
||||||
|
$account->bot = ($publicContact['contact-type'] == Contact::TYPE_NEWS);
|
||||||
|
|
||||||
return $account;
|
return $account;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue