Update Api Transformers, force string type for ids

This commit is contained in:
Daniel Supernault 2019-01-27 19:40:36 -07:00
parent d8bd9f7f0c
commit 261c33e7d8
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
8 changed files with 16 additions and 12 deletions

View file

@ -9,8 +9,9 @@ class AccountTransformer extends Fractal\TransformerAbstract
{
public function transform(Profile $profile)
{
$is_admin = $profile->domain ? false : $profile->user->is_admin;
return [
'id' => $profile->id,
'id' => (string) $profile->id,
'username' => $profile->username,
'acct' => $profile->username,
'display_name' => $profile->name,
@ -28,7 +29,8 @@ class AccountTransformer extends Fractal\TransformerAbstract
'moved' => null,
'fields' => null,
'bot' => null,
'software' => 'pixelfed'
'software' => 'pixelfed',
'is_admin' => (bool) $is_admin
];
}
}

View file

@ -9,7 +9,7 @@ class AttachmentTransformer extends Fractal\TransformerAbstract
public function transform(Media $media)
{
return [
'id' => $media->id,
'id' => (string) $media->id,
'type' => $media->activityVerb(),
'url' => $media->url(),
'remote_url' => null,

View file

@ -10,7 +10,7 @@ class MediaTransformer extends Fractal\TransformerAbstract
public function transform(Media $media)
{
return [
'id' => $media->id,
'id' => (string) $media->id,
'type' => $media->activityVerb(),
'url' => $media->url(),
'remote_url' => null,

View file

@ -10,7 +10,7 @@ class MentionTransformer extends Fractal\TransformerAbstract
public function transform(Profile $profile)
{
return [
'id' => $profile->id,
'id' => (string) $profile->id,
'url' => $profile->url(),
'username' => $profile->username,
'acct' => $profile->username,

View file

@ -15,7 +15,7 @@ class NotificationTransformer extends Fractal\TransformerAbstract
public function transform(Notification $notification)
{
return [
'id' => $notification->id,
'id' => (string) $notification->id,
'type' => $this->replaceTypeVerb($notification->action),
'created_at' => (string) $notification->created_at,
'account' => null,

View file

@ -2,6 +2,7 @@
namespace App\Transformer\Api;
use Auth;
use App\Profile;
use League\Fractal;
@ -9,17 +10,18 @@ class RelationshipTransformer extends Fractal\TransformerAbstract
{
public function transform(Profile $profile)
{
$user = Auth::user()->profile;
return [
'id' => $profile->id,
'following' => null,
'followed_by' => null,
'id' => (string) $profile->id,
'following' => $user->follows($profile),
'followed_by' => $user->followedBy($profile),
'blocking' => null,
'muting' => null,
'muting_notifications' => null,
'requested' => null,
'domain_blocking' => null,
'showing_reblogs' => null,
'endorsed' => null
'endorsed' => false
];
}
}

View file

@ -17,7 +17,7 @@ class StatusTransformer extends Fractal\TransformerAbstract
public function transform(Status $status)
{
return [
'id' => $status->id,
'id' => (string) $status->id,
'uri' => $status->url(),
'url' => $status->url(),
'in_reply_to_id' => $status->in_reply_to_id,

View file

@ -14,7 +14,7 @@ class StoryTransformer extends Fractal\TransformerAbstract
public function transform(Story $story)
{
return [
'id' => $story->id,
'id' => (string) $story->id,
'photo' => $story->profile->avatarUrl(),
'name' => '',
'link' => '',