mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Update NotificationTransformer
This commit is contained in:
parent
601992ed48
commit
7a9a06e0fd
1 changed files with 2 additions and 21 deletions
|
@ -5,15 +5,12 @@ namespace App\Transformer\Api;
|
||||||
use App\Notification;
|
use App\Notification;
|
||||||
use App\Services\AccountService;
|
use App\Services\AccountService;
|
||||||
use App\Services\HashidService;
|
use App\Services\HashidService;
|
||||||
|
use App\Services\RelationshipService;
|
||||||
use App\Services\StatusService;
|
use App\Services\StatusService;
|
||||||
use League\Fractal;
|
use League\Fractal;
|
||||||
|
|
||||||
class NotificationTransformer extends Fractal\TransformerAbstract
|
class NotificationTransformer extends Fractal\TransformerAbstract
|
||||||
{
|
{
|
||||||
protected $defaultIncludes = [
|
|
||||||
// 'relationship',
|
|
||||||
];
|
|
||||||
|
|
||||||
public function transform(Notification $notification)
|
public function transform(Notification $notification)
|
||||||
{
|
{
|
||||||
$res = [
|
$res = [
|
||||||
|
@ -23,21 +20,10 @@ class NotificationTransformer extends Fractal\TransformerAbstract
|
||||||
];
|
];
|
||||||
|
|
||||||
$n = $notification;
|
$n = $notification;
|
||||||
if($n->item_id && $n->item_type == 'App\Status' && in_array($n->action, ['group:comment'])) {
|
|
||||||
$status = $n->status;
|
|
||||||
$res['group_id'] = $status->group_id;
|
|
||||||
|
|
||||||
if($n->action == 'group:comment') {
|
|
||||||
$res['group_post_url'] = GroupPost::whereStatusId($status->id)->first()->url();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(in_array($n->action, ['group.join.approved', 'group.join.rejected', 'group.like'])) {
|
|
||||||
$res['group'] = GroupService::get($n->item_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($n->actor_id) {
|
if($n->actor_id) {
|
||||||
$res['account'] = AccountService::get($n->actor_id);
|
$res['account'] = AccountService::get($n->actor_id);
|
||||||
|
$res['relationship'] = RelationshipService::get($n->actor_id, $n->profile_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($n->item_id && $n->item_type == 'App\Status') {
|
if($n->item_id && $n->item_type == 'App\Status') {
|
||||||
|
@ -89,9 +75,4 @@ class NotificationTransformer extends Fractal\TransformerAbstract
|
||||||
|
|
||||||
return $verbs[$verb];
|
return $verbs[$verb];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function includeRelationship(Notification $notification)
|
|
||||||
{
|
|
||||||
return $this->item($notification->actor, new RelationshipTransformer());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue