From b6c06c4b1d57a7633088463d2de5d47e269b93e0 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 17 Nov 2022 21:53:25 -0700 Subject: [PATCH] Update NotificationTransformer, fix mediaTag and modLog types --- .../Api/NotificationTransformer.php | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/Transformer/Api/NotificationTransformer.php b/app/Transformer/Api/NotificationTransformer.php index df8d0d30c..d4f84bbef 100644 --- a/app/Transformer/Api/NotificationTransformer.php +++ b/app/Transformer/Api/NotificationTransformer.php @@ -32,18 +32,22 @@ class NotificationTransformer extends Fractal\TransformerAbstract if($n->item_id && $n->item_type == 'App\ModLog') { $ml = $n->item; - $res['modlog'] = [ - 'id' => $ml->object_uid, - 'url' => url('/i/admin/users/modlogs/' . $ml->object_uid) - ]; + if($ml && $ml->object_uid) { + $res['modlog'] = [ + 'id' => $ml->object_uid, + 'url' => url('/i/admin/users/modlogs/' . $ml->object_uid) + ]; + } } if($n->item_id && $n->item_type == 'App\MediaTag') { $ml = $n->item; - $res['tagged'] = [ - 'username' => $ml->tagged_username, - 'post_url' => '/p/'.HashidService::encode($ml->status_id) - ]; + if($ml && $ml->tagged_username) { + $res['tagged'] = [ + 'username' => $ml->tagged_username, + 'post_url' => '/p/'.HashidService::encode($ml->status_id) + ]; + } } return $res;