1
0
Fork 0

The account fields are rearrange to match Mastodon

This commit is contained in:
Michael 2020-09-01 20:59:50 +00:00
parent 6f24eeb641
commit 7b903e1ca8

View file

@ -46,14 +46,14 @@ class Account extends BaseEntity
protected $display_name; protected $display_name;
/** @var bool */ /** @var bool */
protected $locked; protected $locked;
/** @var string (Datetime) */ /** @var bool|null */
protected $bot = null;
/** @var bool */
protected $discoverable;
/** @var bool */
protected $group;
/** @var string|null (Datetime) */
protected $created_at; protected $created_at;
/** @var int */
protected $followers_count;
/** @var int */
protected $following_count;
/** @var int */
protected $statuses_count;
/** @var string */ /** @var string */
protected $note; protected $note;
/** @var string (URL)*/ /** @var string (URL)*/
@ -66,20 +66,20 @@ class Account extends BaseEntity
protected $header; protected $header;
/** @var string (URL) */ /** @var string (URL) */
protected $header_static; protected $header_static;
/** @var int */
protected $followers_count;
/** @var int */
protected $following_count;
/** @var int */
protected $statuses_count;
/** @var string|null (Datetime) */
protected $last_status_at = null;
/** @var Emoji[] */ /** @var Emoji[] */
protected $emojis; protected $emojis;
/** @var Account|null */ /** @var Account|null */
protected $moved = null; protected $moved = null;
/** @var Field[]|null */ /** @var Field[]|null */
protected $fields = null; protected $fields = null;
/** @var bool|null */
protected $bot = null;
/** @var bool */
protected $group;
/** @var bool */
protected $discoverable;
/** @var string|null (Datetime) */
protected $last_status_at = null;
/** /**
* Creates an account record from a public 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.
@ -92,7 +92,7 @@ class Account extends BaseEntity
*/ */
public function __construct(BaseURL $baseUrl, array $publicContact, Fields $fields, array $apcontact = [], array $userContact = []) public function __construct(BaseURL $baseUrl, array $publicContact, Fields $fields, array $apcontact = [], array $userContact = [])
{ {
$this->id = $publicContact['id']; $this->id = (string)$publicContact['id'];
$this->username = $publicContact['nick']; $this->username = $publicContact['nick'];
$this->acct = $this->acct =
strpos($publicContact['url'], $baseUrl->get() . '/') === 0 ? strpos($publicContact['url'], $baseUrl->get() . '/') === 0 ?
@ -100,10 +100,10 @@ class Account extends BaseEntity
$publicContact['addr']; $publicContact['addr'];
$this->display_name = $publicContact['name']; $this->display_name = $publicContact['name'];
$this->locked = !empty($apcontact['manually-approve']); $this->locked = !empty($apcontact['manually-approve']);
$this->bot = ($publicContact['contact-type'] == Contact::TYPE_NEWS);
$this->discoverable = !$publicContact['unsearchable'];
$this->group = ($publicContact['contact-type'] == Contact::TYPE_COMMUNITY);
$this->created_at = DateTimeFormat::utc($publicContact['created'], DateTimeFormat::ATOM); $this->created_at = DateTimeFormat::utc($publicContact['created'], DateTimeFormat::ATOM);
$this->followers_count = $apcontact['followers_count'] ?? 0;
$this->following_count = $apcontact['following_count'] ?? 0;
$this->statuses_count = $apcontact['statuses_count'] ?? 0;
$this->note = BBCode::convert($publicContact['about'], false); $this->note = BBCode::convert($publicContact['about'], false);
$this->url = $publicContact['url']; $this->url = $publicContact['url'];
$this->avatar = $userContact['avatar'] ?? $publicContact['avatar']; $this->avatar = $userContact['avatar'] ?? $publicContact['avatar'];
@ -111,18 +111,20 @@ class Account extends BaseEntity
// No header picture in Friendica // No header picture in Friendica
$this->header = ''; $this->header = '';
$this->header_static = ''; $this->header_static = '';
// No custom emojis per account in Friendica $this->followers_count = $apcontact['followers_count'] ?? 0;
$this->emojis = []; $this->following_count = $apcontact['following_count'] ?? 0;
// No metadata fields in Friendica $this->statuses_count = $apcontact['statuses_count'] ?? 0;
$this->fields = $fields->getArrayCopy();
$this->bot = ($publicContact['contact-type'] == Contact::TYPE_NEWS);
$this->group = ($publicContact['contact-type'] == Contact::TYPE_COMMUNITY);
$this->discoverable = !$publicContact['unsearchable'];
$publicContactLastItem = $publicContact['last-item'] ?: DBA::NULL_DATETIME; $publicContactLastItem = $publicContact['last-item'] ?: DBA::NULL_DATETIME;
$userContactLastItem = $userContact['last-item'] ?? DBA::NULL_DATETIME; $userContactLastItem = $userContact['last-item'] ?? DBA::NULL_DATETIME;
$lastItem = $userContactLastItem > $publicContactLastItem ? $userContactLastItem : $publicContactLastItem; $lastItem = $userContactLastItem > $publicContactLastItem ? $userContactLastItem : $publicContactLastItem;
$this->last_status_at = $lastItem != DBA::NULL_DATETIME ? DateTimeFormat::utc($lastItem, DateTimeFormat::ATOM) : null; $this->last_status_at = $lastItem != DBA::NULL_DATETIME ? DateTimeFormat::utc($lastItem, 'Y-m-d') : null;
// No custom emojis per account in Friendica
$this->emojis = [];
// No metadata fields in Friendica
$this->fields = $fields->getArrayCopy();
} }
} }