mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-23 21:43:17 +00:00
Update Profile model
This commit is contained in:
parent
fb24f382c0
commit
8420a839d9
1 changed files with 33 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue