mirror of
https://github.com/friendica/friendica
synced 2024-11-10 23:02:55 +00:00
Add user contact data superseding to Mastodon\Account::create
This commit is contained in:
parent
c286772fb5
commit
0dbce6e58b
2 changed files with 9 additions and 5 deletions
|
@ -66,10 +66,11 @@ class Account
|
||||||
* @param BaseURL $baseUrl
|
* @param BaseURL $baseUrl
|
||||||
* @param array $publicContact Full contact table record with uid = 0
|
* @param array $publicContact Full contact table record with uid = 0
|
||||||
* @param array $apcontact Optional full apcontact table record
|
* @param array $apcontact Optional full apcontact table record
|
||||||
|
* @param array $userContact Optional full contact table record with uid = local_user()
|
||||||
* @return Account
|
* @return Account
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @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 = new Account();
|
||||||
$account->id = $publicContact['id'];
|
$account->id = $publicContact['id'];
|
||||||
|
@ -86,8 +87,8 @@ class Account
|
||||||
$account->statuses_count = $apcontact['statuses_count'] ?? 0;
|
$account->statuses_count = $apcontact['statuses_count'] ?? 0;
|
||||||
$account->note = BBCode::convert($publicContact['about'], false);
|
$account->note = BBCode::convert($publicContact['about'], false);
|
||||||
$account->url = $publicContact['url'];
|
$account->url = $publicContact['url'];
|
||||||
$account->avatar = $publicContact['avatar'];
|
$account->avatar = $userContact['avatar'] ?? $publicContact['avatar'];
|
||||||
$account->avatar_static = $publicContact['avatar'];
|
$account->avatar_static = $userContact['avatar'] ?? $publicContact['avatar'];
|
||||||
// No header picture in Friendica
|
// No header picture in Friendica
|
||||||
$account->header = '';
|
$account->header = '';
|
||||||
$account->header_static = '';
|
$account->header_static = '';
|
||||||
|
@ -98,7 +99,9 @@ class Account
|
||||||
$account->bot = ($publicContact['contact-type'] == Contact::TYPE_NEWS);
|
$account->bot = ($publicContact['contact-type'] == Contact::TYPE_NEWS);
|
||||||
$account->group = ($publicContact['contact-type'] == Contact::TYPE_COMMUNITY);
|
$account->group = ($publicContact['contact-type'] == Contact::TYPE_COMMUNITY);
|
||||||
$account->discoverable = !$publicContact['unsearchable'];
|
$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;
|
return $account;
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,8 +105,9 @@ class FollowRequests extends Api
|
||||||
}
|
}
|
||||||
|
|
||||||
$publicContact = Contact::getById($cdata['public']);
|
$publicContact = Contact::getById($cdata['public']);
|
||||||
|
$userContact = Contact::getById($cdata['user']);
|
||||||
$apcontact = APContact::getByURL($publicContact['url'], false);
|
$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
|
// Not ideal, the same "account" can have multiple ids depending on the context
|
||||||
$account->id = $intro['id'];
|
$account->id = $intro['id'];
|
||||||
|
|
Loading…
Reference in a new issue