mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Update mastoapi transformers
This commit is contained in:
parent
41cc741be6
commit
89206d6e1f
4 changed files with 15 additions and 16 deletions
|
@ -11,7 +11,6 @@ class AccountTransformer extends Fractal\TransformerAbstract
|
||||||
public function transform(Profile $profile)
|
public function transform(Profile $profile)
|
||||||
{
|
{
|
||||||
$local = $profile->domain == null;
|
$local = $profile->domain == null;
|
||||||
$is_admin = !$local ? false : $profile->user->is_admin;
|
|
||||||
$username = $local ? $profile->username : explode('@', substr($profile->username, 1))[0];
|
$username = $local ? $profile->username : explode('@', substr($profile->username, 1))[0];
|
||||||
return [
|
return [
|
||||||
'id' => (string) $profile->id,
|
'id' => (string) $profile->id,
|
||||||
|
@ -19,22 +18,21 @@ class AccountTransformer extends Fractal\TransformerAbstract
|
||||||
'acct' => $username,
|
'acct' => $username,
|
||||||
'display_name' => $profile->name,
|
'display_name' => $profile->name,
|
||||||
'locked' => (bool) $profile->is_private,
|
'locked' => (bool) $profile->is_private,
|
||||||
|
'bot' => false,
|
||||||
'created_at' => $profile->created_at->toJSON(),
|
'created_at' => $profile->created_at->toJSON(),
|
||||||
'followers_count' => $profile->followerCount(),
|
|
||||||
'following_count' => $profile->followingCount(),
|
|
||||||
'statuses_count' => (int) $profile->statusCount(),
|
|
||||||
'note' => $profile->bio ?? '',
|
'note' => $profile->bio ?? '',
|
||||||
'url' => $profile->url(),
|
'url' => $profile->url(),
|
||||||
'avatar' => $profile->avatarUrl(),
|
'avatar' => $profile->avatarUrl(),
|
||||||
'avatar_static' => $profile->avatarUrl(),
|
'avatar_static' => $profile->avatarUrl(),
|
||||||
'header' => '',
|
'header' => '',
|
||||||
'header_static' => '',
|
'header_static' => '',
|
||||||
|
'followers_count' => (int) $profile->followerCount(),
|
||||||
|
'following_count' => (int) $profile->followingCount(),
|
||||||
|
'statuses_count' => (int) $profile->statusCount(),
|
||||||
|
'last_status_at' => optional($profile->last_status_at)->toJSON(),
|
||||||
'emojis' => [],
|
'emojis' => [],
|
||||||
'moved' => null,
|
'moved' => null,
|
||||||
'fields' => null,
|
'fields' => [],
|
||||||
'bot' => false,
|
|
||||||
'software' => 'pixelfed',
|
|
||||||
'is_admin' => (bool) $is_admin,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,10 +13,9 @@ class MediaTransformer extends Fractal\TransformerAbstract
|
||||||
'id' => (string) $media->id,
|
'id' => (string) $media->id,
|
||||||
'type' => lcfirst($media->activityVerb()),
|
'type' => lcfirst($media->activityVerb()),
|
||||||
'url' => $media->url(),
|
'url' => $media->url(),
|
||||||
'remote_url' => null,
|
|
||||||
'preview_url' => $media->thumbnailUrl(),
|
'preview_url' => $media->thumbnailUrl(),
|
||||||
'text_url' => null,
|
'remote_url' => $media->remote_url,
|
||||||
'meta' => null,
|
'text_url' => $media->url(),
|
||||||
'description' => $media->caption,
|
'description' => $media->caption,
|
||||||
'blurhash' => $media->blurhash ?? 'U4Rfzst8?bt7ogayj[j[~pfQ9Goe%Mj[WBay'
|
'blurhash' => $media->blurhash ?? 'U4Rfzst8?bt7ogayj[j[~pfQ9Goe%Mj[WBay'
|
||||||
];
|
];
|
||||||
|
|
|
@ -9,11 +9,13 @@ class MentionTransformer extends Fractal\TransformerAbstract
|
||||||
{
|
{
|
||||||
public function transform(Profile $profile)
|
public function transform(Profile $profile)
|
||||||
{
|
{
|
||||||
|
$local = $profile->domain == null;
|
||||||
|
$username = $local ? $profile->username : explode('@', substr($profile->username, 1))[0];
|
||||||
return [
|
return [
|
||||||
'id' => (string) $profile->id,
|
'id' => (string) $profile->id,
|
||||||
'url' => $profile->url(),
|
'url' => $profile->url(),
|
||||||
'username' => $profile->username,
|
'username' => $profile->username,
|
||||||
'acct' => $profile->username,
|
'acct' => $username,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,14 @@ class StatusTransformer extends Fractal\TransformerAbstract
|
||||||
'id' => (string) $status->id,
|
'id' => (string) $status->id,
|
||||||
'created_at' => $status->created_at->toJSON(),
|
'created_at' => $status->created_at->toJSON(),
|
||||||
'in_reply_to_id' => $status->in_reply_to_id ? (string) $status->in_reply_to_id : null,
|
'in_reply_to_id' => $status->in_reply_to_id ? (string) $status->in_reply_to_id : null,
|
||||||
'in_reply_to_account_id' => $status->in_reply_to_profile_id,
|
'in_reply_to_account_id' => $status->in_reply_to_profile_id ? (string) $status->in_reply_to_profile_id : null,
|
||||||
'sensitive' => (bool) $status->is_nsfw,
|
'sensitive' => (bool) $status->is_nsfw,
|
||||||
'spoiler_text' => $status->cw_summary ?? '',
|
'spoiler_text' => $status->cw_summary ?? '',
|
||||||
'visibility' => $status->visibility ?? $status->scope,
|
'visibility' => $status->visibility ?? $status->scope,
|
||||||
'language' => 'en',
|
'language' => 'en',
|
||||||
'uri' => $status->url(),
|
'uri' => $status->permalink(''),
|
||||||
'url' => $status->url(),
|
'url' => $status->url(),
|
||||||
'replies_count' => 0,
|
'replies_count' => $status->reply_count ?? 0,
|
||||||
'reblogs_count' => $status->reblogs_count ?? 0,
|
'reblogs_count' => $status->reblogs_count ?? 0,
|
||||||
'favourites_count' => $status->likes_count ?? 0,
|
'favourites_count' => $status->likes_count ?? 0,
|
||||||
'reblogged' => $status->shared(),
|
'reblogged' => $status->shared(),
|
||||||
|
|
Loading…
Reference in a new issue