Skip to content
This repository has been archived by the owner on Aug 31, 2024. It is now read-only.

Commit

Permalink
include full actor in update request
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronpk committed Sep 1, 2018
1 parent 249c022 commit 321c1df
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 39 deletions.
2 changes: 1 addition & 1 deletion app/Console/Commands/SendProfileUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function handle()
$activity->type = 'Update';
$activity->user_id = $user->id;
$activity->setData([
'object' => $user->actorURL()
'object' => $user->toActivityStreamsObject()
]);
$activity->save();

Expand Down
39 changes: 1 addition & 38 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,46 +25,9 @@ public function get($username, $format=false) {

// Switch on Accept header
if((!$format && request()->wantsJson()) || $format == 'json') {
$profile = [
"@context" => [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
],
"id" => $user->actorURL(),
"type" => "Person",
"preferredUsername" => $user->username,
"url" => $user->actorURL(),
"icon" => [
"type" => "Image",
"mediaType" => "image/jpeg",
"url" => env('APP_URL')."/storage/images/".$user->username.".jpg",
],
"inbox" => env('APP_URL').$user->inboxPath(),
"outbox" => env('APP_URL').$user->outboxPath(),
"featured" => env('APP_URL').$user->featuredPath(),
"publicKey" => [
"id" => $user->actorURL(),
"owner" => $user->actorURL(),
"publicKeyPem" => $user->public_key
]
];

if($user->photo) {
$profile['icon']['url'] = $user->photo;
}

if($user->banner) {
$profile['image'] = [
'type' => 'image',
'mediaType' => 'image/jpeg',
'url' => $user->banner,
];
}
$profile = $user->toActivityStreamsObject();

if($user->external_domain) {
// Override some of the properties
$profile['url'] = 'https://' . $user->external_domain;

// Add the Webfinger bits to this response
$profile['---webfinger---'] = '---webfinger---';
$profile['subject'] = 'acct:' . $user->username . '@' . $user->external_domain;
Expand Down
45 changes: 45 additions & 0 deletions app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,49 @@ public function outboxPath() {
public function featuredPath() {
return '/' . $this->username . '/featured';
}

public function toActivityStreamsObject() {
$profile = [
"@context" => [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
],
"id" => $this->actorURL(),
"type" => "Person",
"preferredUsername" => $this->username,
"url" => $this->actorURL(),
"icon" => [
"type" => "Image",
"mediaType" => "image/jpeg",
"url" => env('APP_URL')."/storage/images/".$this->username.".jpg",
],
"inbox" => env('APP_URL').$this->inboxPath(),
"outbox" => env('APP_URL').$this->outboxPath(),
"featured" => env('APP_URL').$this->featuredPath(),
"publicKey" => [
"id" => $this->actorURL(),
"owner" => $this->actorURL(),
"publicKeyPem" => $this->public_key
]
];

if($this->photo) {
$profile['icon']['url'] = $this->photo;
}

if($this->banner) {
$profile['image'] = [
'type' => 'image',
'mediaType' => 'image/jpeg',
'url' => $this->banner,
];
}

if($this->external_domain) {
// Override some of the properties
$profile['url'] = 'https://' . $this->external_domain;
}

return $profile;
}
}

0 comments on commit 321c1df

Please sign in to comment.