pixelfed/app/Transformer/Api/Mastodon/v1/AccountTransformer.php

41 lines
1.2 KiB
PHP
Raw Normal View History

2019-09-26 07:30:15 +00:00
<?php
namespace App\Transformer\Api\Mastodon\v1;
use App\Profile;
use League\Fractal;
class AccountTransformer extends Fractal\TransformerAbstract
{
public function transform(Profile $profile)
{
$local = $profile->domain == null;
$is_admin = !$local ? false : $profile->user->is_admin;
$acct = $local ? $profile->username . '@' . config('pixelfed.domain.app') : substr($profile->username, 1);
2019-09-26 07:30:15 +00:00
$username = $local ? $profile->username : explode('@', $acct)[0];
return [
'id' => (string) $profile->id,
'username' => $username,
'acct' => $acct,
'display_name' => $profile->name,
'locked' => (bool) $profile->is_private,
'created_at' => $profile->created_at->toIso8601ZuluString(),
2019-09-26 07:30:15 +00:00
'followers_count' => $profile->followerCount(),
'following_count' => $profile->followingCount(),
'statuses_count' => (int) $profile->statusCount(),
'note' => $profile->bio ?? '',
'url' => $profile->url(),
'avatar' => $profile->avatarUrl(),
'avatar_static' => $profile->avatarUrl(),
'header' => '',
'header_static' => '',
'emojis' => [],
'moved' => null,
2019-09-27 03:53:55 +00:00
'fields' => null,
'bot' => null,
2019-09-26 07:30:15 +00:00
'software' => 'pixelfed',
'is_admin' => (bool) $is_admin,
];
}
}