mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-25 06:23:18 +00:00
Update AccountTransformer
This commit is contained in:
parent
6fbbe3202e
commit
403163f12f
1 changed files with 10 additions and 5 deletions
|
@ -14,14 +14,17 @@ class AccountTransformer extends Fractal\TransformerAbstract
|
||||||
|
|
||||||
public function transform(Profile $profile)
|
public function transform(Profile $profile)
|
||||||
{
|
{
|
||||||
$is_admin = $profile->domain ? false : $profile->user->is_admin;
|
$local = $profile->domain == null;
|
||||||
|
$is_admin = !$local ? false : $profile->user->is_admin;
|
||||||
|
$acct = $local ? $profile->username : substr($profile->username, 1);
|
||||||
|
$username = $local ? $profile->username : explode('@', $profile->username)[0];
|
||||||
return [
|
return [
|
||||||
'id' => (string) $profile->id,
|
'id' => (string) $profile->id,
|
||||||
'username' => $profile->username,
|
'username' => $username,
|
||||||
'acct' => $profile->username,
|
'acct' => $acct,
|
||||||
'display_name' => $profile->name,
|
'display_name' => $profile->name,
|
||||||
'locked' => (bool) $profile->is_private,
|
'locked' => (bool) $profile->is_private,
|
||||||
'created_at' => null,
|
'created_at' => $profile->created_at->toISOString(),
|
||||||
'followers_count' => $profile->followerCount(),
|
'followers_count' => $profile->followerCount(),
|
||||||
'following_count' => $profile->followingCount(),
|
'following_count' => $profile->followingCount(),
|
||||||
'statuses_count' => (int) $profile->statusCount(),
|
'statuses_count' => (int) $profile->statusCount(),
|
||||||
|
@ -33,11 +36,13 @@ class AccountTransformer extends Fractal\TransformerAbstract
|
||||||
'header_static' => null,
|
'header_static' => null,
|
||||||
'header_bg' => $profile->header_bg,
|
'header_bg' => $profile->header_bg,
|
||||||
'moved' => null,
|
'moved' => null,
|
||||||
'fields' => null,
|
'fields' => [],
|
||||||
'bot' => null,
|
'bot' => null,
|
||||||
'website' => $profile->website,
|
'website' => $profile->website,
|
||||||
'software' => 'pixelfed',
|
'software' => 'pixelfed',
|
||||||
'is_admin' => (bool) $is_admin,
|
'is_admin' => (bool) $is_admin,
|
||||||
|
'last_status_at' => null,
|
||||||
|
'emojis' => [],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue