From 8420a839d9c573ac0f06130b671ac5c608bd36c5 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 3 Nov 2018 21:20:11 -0600 Subject: [PATCH] Update Profile model --- app/Profile.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/app/Profile.php b/app/Profile.php index 4fe81c033..333cbb200 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -46,6 +46,9 @@ class Profile extends Model public function permalink($suffix = '') { + if($this->remote_url) { + return $this->remote_url; + } return url('users/'.$this->username.$suffix); } @@ -248,4 +251,34 @@ class Profile extends Model { return $this->sharedInbox ?? $this->inboxUrl(); } + + public function getDefaultScope() + { + return $this->is_private == true ? 'private' : 'public'; + } + + public function getAudience($scope = false) + { + if($this->remote_url) { + return []; + } + $scope = $scope ?? $this->getDefaultScope(); + $audience = []; + switch ($scope) { + case 'public': + $audience = [ + 'to' => [ + 'https://www.w3.org/ns/activitystreams#Public' + ], + 'cc' => [ + $this->permalink('/followers') + ] + ]; + break; + + default: + # code... + break; + } + } }