Add user contact data superseding to Mastodon\Account::create
This commit is contained in:
parent
c286772fb5
commit
0dbce6e58b
|
@ -66,10 +66,11 @@ class Account
|
|||
* @param BaseURL $baseUrl
|
||||
* @param array $publicContact Full contact table record with uid = 0
|
||||
* @param array $apcontact Optional full apcontact table record
|
||||
* @param array $userContact Optional full contact table record with uid = local_user()
|
||||
* @return Account
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function create(BaseURL $baseUrl, array $publicContact, array $apcontact = [])
|
||||
public static function create(BaseURL $baseUrl, array $publicContact, array $apcontact = [], array $userContact = [])
|
||||
{
|
||||
$account = new Account();
|
||||
$account->id = $publicContact['id'];
|
||||
|
@ -86,8 +87,8 @@ class Account
|
|||
$account->statuses_count = $apcontact['statuses_count'] ?? 0;
|
||||
$account->note = BBCode::convert($publicContact['about'], false);
|
||||
$account->url = $publicContact['url'];
|
||||
$account->avatar = $publicContact['avatar'];
|
||||
$account->avatar_static = $publicContact['avatar'];
|
||||
$account->avatar = $userContact['avatar'] ?? $publicContact['avatar'];
|
||||
$account->avatar_static = $userContact['avatar'] ?? $publicContact['avatar'];
|
||||
// No header picture in Friendica
|
||||
$account->header = '';
|
||||
$account->header_static = '';
|
||||
|
@ -98,7 +99,9 @@ class Account
|
|||
$account->bot = ($publicContact['contact-type'] == Contact::TYPE_NEWS);
|
||||
$account->group = ($publicContact['contact-type'] == Contact::TYPE_COMMUNITY);
|
||||
$account->discoverable = !$publicContact['unsearchable'];
|
||||
$account->last_status_at = !empty($publicContact['last-item']) ? DateTimeFormat::utc($publicContact['last-item'], DateTimeFormat::ATOM) : null;
|
||||
|
||||
$last_item = $userContact['last-item'] ?? $publicContact['last-item'];
|
||||
$account->last_status_at = !empty($last_item) ? DateTimeFormat::utc($last_item, DateTimeFormat::ATOM) : null;
|
||||
|
||||
return $account;
|
||||
}
|
||||
|
|
|
@ -105,8 +105,9 @@ class FollowRequests extends Api
|
|||
}
|
||||
|
||||
$publicContact = Contact::getById($cdata['public']);
|
||||
$userContact = Contact::getById($cdata['user']);
|
||||
$apcontact = APContact::getByURL($publicContact['url'], false);
|
||||
$account = Mastodon\Account::create($baseUrl, $publicContact, $apcontact);
|
||||
$account = Mastodon\Account::create($baseUrl, $publicContact, $apcontact, $userContact);
|
||||
|
||||
// Not ideal, the same "account" can have multiple ids depending on the context
|
||||
$account->id = $intro['id'];
|
||||
|
|
Loading…
Reference in a new issue