Update AccountTransformer, fixes #1730

This commit is contained in:
Daniel Supernault 2019-10-01 20:53:45 -06:00
parent 715166fc67
commit 21f262315d
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -4,6 +4,7 @@ namespace App\Transformer\Api\Mastodon\v1;
use App\Profile;
use League\Fractal;
use Illuminate\Support\Str;
class AccountTransformer extends Fractal\TransformerAbstract
{
@ -11,12 +12,11 @@ class AccountTransformer extends Fractal\TransformerAbstract
{
$local = $profile->domain == null;
$is_admin = !$local ? false : $profile->user->is_admin;
$acct = $local ? $profile->username . '@' . config('pixelfed.domain.app') : substr($profile->username, 1);
$username = $local ? $profile->username : explode('@', $acct)[0];
$username = $local ? $profile->username : explode('@', substr($profile->username, 1))[0];
return [
'id' => (string) $profile->id,
'username' => $username,
'acct' => $acct,
'acct' => $username,
'display_name' => $profile->name,
'locked' => (bool) $profile->is_private,
'created_at' => $profile->created_at->toJSON(),
@ -32,7 +32,7 @@ class AccountTransformer extends Fractal\TransformerAbstract
'emojis' => [],
'moved' => null,
'fields' => null,
'bot' => null,
'bot' => false,
'software' => 'pixelfed',
'is_admin' => (bool) $is_admin,
];