Use "avatar" instead of "contact"
This commit is contained in:
parent
7e747b2f41
commit
9a1abda314
|
@ -76,22 +76,22 @@ class Account extends BaseFactory
|
||||||
*/
|
*/
|
||||||
public function createFromUriId(int $contactUriId, $uid = 0): \Friendica\Object\Api\Mastodon\Account
|
public function createFromUriId(int $contactUriId, $uid = 0): \Friendica\Object\Api\Mastodon\Account
|
||||||
{
|
{
|
||||||
$contact = DBA::selectFirst('account-user-view', [], ['uri-id' => $contactUriId, 'uid' => [0, $uid]], ['order' => ['id' => true]]);
|
$avatar = DBA::selectFirst('account-user-view', [], ['uri-id' => $contactUriId, 'uid' => [0, $uid]], ['order' => ['id' => true]]);
|
||||||
if (empty($contact)) {
|
if (empty($avatar)) {
|
||||||
throw new HTTPException\NotFoundException('Contact ' . $contactUriId . ' not found');
|
throw new HTTPException\NotFoundException('Contact ' . $contactUriId . ' not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = new Fields();
|
$fields = new Fields();
|
||||||
|
|
||||||
if (Contact::isLocal($contact['url'])) {
|
if (Contact::isLocal($avatar['url'])) {
|
||||||
$self_contact = Contact::selectFirst(['uid'], ['nurl' => $contact['nurl'], 'self' => true]);
|
$self_contact = Contact::selectFirst(['uid'], ['nurl' => $avatar['nurl'], 'self' => true]);
|
||||||
if (!empty($self_contact['uid'])) {
|
if (!empty($self_contact['uid'])) {
|
||||||
$profileFields = $this->profileFieldRepo->selectPublicFieldsByUserId($self_contact['uid']);
|
$profileFields = $this->profileFieldRepo->selectPublicFieldsByUserId($self_contact['uid']);
|
||||||
$fields = $this->mstdnFieldFactory->createFromProfileFields($profileFields);
|
$fields = $this->mstdnFieldFactory->createFromProfileFields($profileFields);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new \Friendica\Object\Api\Mastodon\Account($this->baseUrl, $contact, $fields);
|
return new \Friendica\Object\Api\Mastodon\Account($this->baseUrl, $avatar, $fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,10 +101,10 @@ class Account extends BaseFactory
|
||||||
*/
|
*/
|
||||||
public function createFromUserId(int $userId): \Friendica\Object\Api\Mastodon\Account
|
public function createFromUserId(int $userId): \Friendica\Object\Api\Mastodon\Account
|
||||||
{
|
{
|
||||||
$contact = DBA::selectFirst('account-user-view', [], ['uid' => $userId, 'self' => true]);
|
$avatar = DBA::selectFirst('account-user-view', [], ['uid' => $userId, 'self' => true]);
|
||||||
$profileFields = $this->profileFieldRepo->selectPublicFieldsByUserId($userId);
|
$profileFields = $this->profileFieldRepo->selectPublicFieldsByUserId($userId);
|
||||||
$fields = $this->mstdnFieldFactory->createFromProfileFields($profileFields);
|
$fields = $this->mstdnFieldFactory->createFromProfileFields($profileFields);
|
||||||
|
|
||||||
return new \Friendica\Object\Api\Mastodon\Account($this->baseUrl, $contact, $fields);
|
return new \Friendica\Object\Api\Mastodon\Account($this->baseUrl, $avatar, $fields);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ class Status extends BaseFactory
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
* @throws ImagickException|HTTPException\NotFoundException
|
* @throws ImagickException|HTTPException\NotFoundException
|
||||||
*/
|
*/
|
||||||
public function createFromUriId(int $uriId, $uid = 0, $item = []): \Friendica\Object\Api\Mastodon\Status
|
public function createFromUriId(int $uriId, $uid = 0): \Friendica\Object\Api\Mastodon\Status
|
||||||
{
|
{
|
||||||
$fields = ['uri-id', 'uid', 'author-id', 'author-uri-id', 'author-link', 'starred', 'app', 'title', 'body', 'raw-body', 'content-warning', 'question-id',
|
$fields = ['uri-id', 'uid', 'author-id', 'author-uri-id', 'author-link', 'starred', 'app', 'title', 'body', 'raw-body', 'content-warning', 'question-id',
|
||||||
'created', 'network', 'thr-parent-id', 'parent-author-id', 'language', 'uri', 'plink', 'private', 'vid', 'gravity', 'featured', 'has-media'];
|
'created', 'network', 'thr-parent-id', 'parent-author-id', 'language', 'uri', 'plink', 'private', 'vid', 'gravity', 'featured', 'has-media'];
|
||||||
|
|
|
@ -86,37 +86,37 @@ class Account extends BaseDataTransferObject
|
||||||
* 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.
|
||||||
*
|
*
|
||||||
* @param BaseURL $baseUrl
|
* @param BaseURL $baseUrl
|
||||||
* @param array $contact entry of "account-user-view"
|
* @param array $avatar entry of "account-user-view"
|
||||||
* @param Fields $fields Profile fields
|
* @param Fields $fields Profile fields
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public function __construct(BaseURL $baseUrl, array $contact, Fields $fields)
|
public function __construct(BaseURL $baseUrl, array $avatar, Fields $fields)
|
||||||
{
|
{
|
||||||
$this->id = (string)$contact['pid'];
|
$this->id = (string)$avatar['pid'];
|
||||||
$this->username = $contact['nick'];
|
$this->username = $avatar['nick'];
|
||||||
$this->acct =
|
$this->acct =
|
||||||
strpos($contact['url'], $baseUrl->get() . '/') === 0 ?
|
strpos($avatar['url'], $baseUrl->get() . '/') === 0 ?
|
||||||
$contact['nick'] :
|
$avatar['nick'] :
|
||||||
$contact['addr'];
|
$avatar['addr'];
|
||||||
$this->display_name = $contact['name'];
|
$this->display_name = $avatar['name'];
|
||||||
$this->locked = (bool)$contact['manually-approve'];
|
$this->locked = (bool)$avatar['manually-approve'];
|
||||||
$this->bot = ($contact['contact-type'] == Contact::TYPE_NEWS);
|
$this->bot = ($avatar['contact-type'] == Contact::TYPE_NEWS);
|
||||||
$this->discoverable = !$contact['unsearchable'];
|
$this->discoverable = !$avatar['unsearchable'];
|
||||||
$this->group = ($contact['contact-type'] == Contact::TYPE_COMMUNITY);
|
$this->group = ($avatar['contact-type'] == Contact::TYPE_COMMUNITY);
|
||||||
|
|
||||||
$this->created_at = DateTimeFormat::utc($contact['created'] ?: DBA::NULL_DATETIME, DateTimeFormat::JSON);
|
$this->created_at = DateTimeFormat::utc($avatar['created'] ?: DBA::NULL_DATETIME, DateTimeFormat::JSON);
|
||||||
|
|
||||||
$this->note = BBCode::convertForUriId($contact['uri-id'], $contact['about'], BBCode::EXTERNAL);
|
$this->note = BBCode::convertForUriId($avatar['uri-id'], $avatar['about'], BBCode::EXTERNAL);
|
||||||
$this->url = $contact['url'];
|
$this->url = $avatar['url'];
|
||||||
$this->avatar = Contact::getAvatarUrlForId($contact['id'] ?? 0 ?: $contact['pid'], Proxy::SIZE_SMALL, $contact['updated'], $contact['guid'] ?? '');
|
$this->avatar = Contact::getAvatarUrlForId($avatar['id'] ?? 0 ?: $avatar['pid'], Proxy::SIZE_SMALL, $avatar['updated'], $avatar['guid'] ?? '');
|
||||||
$this->avatar_static = $this->avatar;
|
$this->avatar_static = $this->avatar;
|
||||||
$this->header = Contact::getHeaderUrlForId($contact['id'] ?? 0 ?: $contact['pid'], '', $contact['updated'], $contact['guid'] ?? '');
|
$this->header = Contact::getHeaderUrlForId($avatar['id'] ?? 0 ?: $avatar['pid'], '', $avatar['updated'], $avatar['guid'] ?? '');
|
||||||
$this->header_static = $this->header;
|
$this->header_static = $this->header;
|
||||||
$this->followers_count = $contact['ap-followers_count'] ?? $contact['diaspora-interacted_count'] ?? 0;
|
$this->followers_count = $avatar['ap-followers_count'] ?? $avatar['diaspora-interacted_count'] ?? 0;
|
||||||
$this->following_count = $contact['ap-following_count'] ?? $contact['diaspora-interacting_count'] ?? 0;
|
$this->following_count = $avatar['ap-following_count'] ?? $avatar['diaspora-interacting_count'] ?? 0;
|
||||||
$this->statuses_count = $contact['ap-statuses_count'] ?? $contact['diaspora-post_count'] ?? 0;
|
$this->statuses_count = $avatar['ap-statuses_count'] ?? $avatar['diaspora-post_count'] ?? 0;
|
||||||
|
|
||||||
$lastItem = $contact['last-item'] ?: DBA::NULL_DATETIME;
|
$lastItem = $avatar['last-item'] ?: DBA::NULL_DATETIME;
|
||||||
$this->last_status_at = $lastItem != DBA::NULL_DATETIME ? DateTimeFormat::utc($lastItem, 'Y-m-d') : null;
|
$this->last_status_at = $lastItem != DBA::NULL_DATETIME ? DateTimeFormat::utc($lastItem, 'Y-m-d') : null;
|
||||||
|
|
||||||
// No custom emojis per account in Friendica
|
// No custom emojis per account in Friendica
|
||||||
|
|
Loading…
Reference in a new issue