Update NotificationTransformer, add modlog and tagged types

This commit is contained in:
Daniel Supernault 2020-07-15 10:37:37 -06:00
parent 9db71f8b77
commit 49dab6fb5a
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -14,7 +14,8 @@ class NotificationTransformer extends Fractal\TransformerAbstract
'account',
'status',
'relationship',
'modlog'
'modlog',
'tagged'
];
public function transform(Notification $notification)
@ -55,7 +56,8 @@ class NotificationTransformer extends Fractal\TransformerAbstract
'share' => 'share',
'like' => 'favourite',
'comment' => 'comment',
'admin.user.modlog.comment' => 'modlog'
'admin.user.modlog.comment' => 'modlog',
'tagged' => 'tagged'
];
return $verbs[$verb];
}
@ -85,4 +87,22 @@ class NotificationTransformer extends Fractal\TransformerAbstract
return null;
}
}
public function includeTagged(Notification $notification)
{
$n = $notification;
if($n->item_id && $n->item_type == 'App\MediaTag') {
$ml = $n->item;
$res = $this->item($ml, function($ml) {
return [
'username' => $ml->status->profile->username,
'post_url' => $ml->status->url()
];
});
return $res;
} else {
return null;
}
}
}