mirror of https://github.com/pixelfed/pixelfed
commit
3da65132c6
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformer\Api;
|
||||
|
||||
use League\Fractal;
|
||||
|
||||
class EmojiTransformer extends Fractal\TransformerAbstract
|
||||
{
|
||||
public function transform($emoji)
|
||||
{
|
||||
return [
|
||||
'shortcode' => '',
|
||||
'static_url' => '',
|
||||
'url' => '',
|
||||
'visible_in_picker' => false
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformer\Api;
|
||||
|
||||
use App\Instance;
|
||||
use League\Fractal;
|
||||
|
||||
class InstanceTransformer extends Fractal\TransformerAbstract
|
||||
{
|
||||
public function transform(Instance $instance)
|
||||
{
|
||||
return [
|
||||
'uri' => $instance->url,
|
||||
'title' => null,
|
||||
'description' => null,
|
||||
'email' => null,
|
||||
'version' => null,
|
||||
'thumbnail' => null,
|
||||
'urls' => [],
|
||||
'stats' => [],
|
||||
'languages' => null,
|
||||
'contact_account' => null
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Transformer\Api;
|
||||
|
||||
use App\Notification;
|
||||
use League\Fractal;
|
||||
|
||||
class NotificationTransformer extends Fractal\TransformerAbstract
|
||||
{
|
||||
protected $defaultIncludes = [
|
||||
'account',
|
||||
'status',
|
||||
];
|
||||
|
||||
public function transform(Notification $notification)
|
||||
{
|
||||
return [
|
||||
'id' => $notification->id,
|
||||
'type' => $this->replaceTypeVerb($notification->action),
|
||||
'created_at' => (string) $notification->created_at,
|
||||
'account' => null,
|
||||
'status' => null
|
||||
];
|
||||
}
|
||||
|
||||
public function includeAccount(Notification $notification)
|
||||
{
|
||||
return $this->item($notification->actor, new AccountTransformer());
|
||||
}
|
||||
|
||||
public function includeStatus(Notification $notification)
|
||||
{
|
||||
$item = $notification->item;
|
||||
if(get_class($item) === 'App\Status') {
|
||||
return $this->item($item, new StatusTransformer());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function replaceTypeVerb($verb)
|
||||
{
|
||||
$verbs = [
|
||||
'follow' => 'follow',
|
||||
'mention' => 'mention',
|
||||
'reblog' => 'share',
|
||||
'like' => 'favourite',
|
||||
];
|
||||
return $verbs[$verb];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue