From 49dab6fb5a0fbc1b84f5c6f4cfb21d1ceee09cad Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 15 Jul 2020 10:37:37 -0600 Subject: [PATCH] Update NotificationTransformer, add modlog and tagged types --- .../Api/NotificationTransformer.php | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/app/Transformer/Api/NotificationTransformer.php b/app/Transformer/Api/NotificationTransformer.php index 7d0d9c5e4..812b250e6 100644 --- a/app/Transformer/Api/NotificationTransformer.php +++ b/app/Transformer/Api/NotificationTransformer.php @@ -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; + } + } }