From aecba4049a7da4d419435f792373f6a8ef3c8211 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 12 Dec 2018 00:16:44 -0700 Subject: [PATCH 1/7] Update Status model, add text type --- app/Status.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Status.php b/app/Status.php index de87c06d0..4769a733b 100644 --- a/app/Status.php +++ b/app/Status.php @@ -22,6 +22,7 @@ class Status extends Model protected $fillable = ['profile_id', 'visibility', 'in_reply_to_id', 'reblog_of_id']; const STATUS_TYPES = [ + 'text', 'photo', 'photo:album', 'video', From c7e030cb301198d4e5fe53882a4093d60ef2cf99 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 12 Dec 2018 13:56:46 -0700 Subject: [PATCH 2/7] Update ProfileTransformer --- app/Transformer/ActivityPub/ProfileTransformer.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/Transformer/ActivityPub/ProfileTransformer.php b/app/Transformer/ActivityPub/ProfileTransformer.php index d270e8c18..97617bdf0 100644 --- a/app/Transformer/ActivityPub/ProfileTransformer.php +++ b/app/Transformer/ActivityPub/ProfileTransformer.php @@ -15,9 +15,6 @@ class ProfileTransformer extends Fractal\TransformerAbstract 'https://w3id.org/security/v1', [ 'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers', - 'featured' => [ - 'https://pixelfed.org/ns#featured' => ['@type' => '@id'], - ], ], ], 'id' => $profile->permalink(), @@ -26,7 +23,7 @@ class ProfileTransformer extends Fractal\TransformerAbstract 'followers' => $profile->permalink('/followers'), 'inbox' => $profile->permalink('/inbox'), 'outbox' => $profile->permalink('/outbox'), - 'featured' => $profile->permalink('/collections/featured'), + //'featured' => $profile->permalink('/collections/featured'), 'preferredUsername' => $profile->username, 'name' => $profile->name, 'summary' => $profile->bio, From 2c110283f9265283d906aee7e1d604c3e1ac28d0 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 12 Dec 2018 14:24:52 -0700 Subject: [PATCH 3/7] Update Media model --- app/Media.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Media.php b/app/Media.php index 131f70a06..fd507e7f1 100644 --- a/app/Media.php +++ b/app/Media.php @@ -46,7 +46,12 @@ class Media extends Model { $verb = 'Image'; switch ($this->mimeType()) { + case 'audio': + $verb = 'Audio'; + break; + case 'image': + $verb = 'Image'; break; case 'video': From 75d16ad99c4799fa8233e20176bf28cf3dbcf97f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 12 Dec 2018 14:25:27 -0700 Subject: [PATCH 4/7] Update AP Note verb transformer --- app/Transformer/ActivityPub/Verb/CreateNote.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/app/Transformer/ActivityPub/Verb/CreateNote.php b/app/Transformer/ActivityPub/Verb/CreateNote.php index b8d3a9a17..49aed880a 100644 --- a/app/Transformer/ActivityPub/Verb/CreateNote.php +++ b/app/Transformer/ActivityPub/Verb/CreateNote.php @@ -30,12 +30,6 @@ class CreateNote extends Fractal\TransformerAbstract '@context' => [ 'https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1', - [ - 'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers', - 'featured' => [ - 'https://pixelfed.org/ns#featured' => ['@type' => '@id'], - ], - ], ], 'id' => $status->permalink(), 'type' => 'Create', @@ -57,7 +51,7 @@ class CreateNote extends Fractal\TransformerAbstract 'sensitive' => (bool) $status->is_nsfw, 'attachment' => $status->media->map(function ($media) { return [ - 'type' => 'Document', + 'type' => $media->activityVerb(), 'mediaType' => $media->mime, 'url' => $media->url(), 'name' => null, From cb650d9d8ae7c2d38c16a615d39c11afa1b97cfb Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 12 Dec 2018 14:26:00 -0700 Subject: [PATCH 5/7] Update AP outbox transformer --- app/Transformer/ActivityPub/ProfileOutbox.php | 73 ++++--------------- 1 file changed, 16 insertions(+), 57 deletions(-) diff --git a/app/Transformer/ActivityPub/ProfileOutbox.php b/app/Transformer/ActivityPub/ProfileOutbox.php index 00e69de95..bd82d9b16 100644 --- a/app/Transformer/ActivityPub/ProfileOutbox.php +++ b/app/Transformer/ActivityPub/ProfileOutbox.php @@ -4,74 +4,33 @@ namespace App\Transformer\ActivityPub; use App\Profile; use League\Fractal; +use App\Transformer\ActivityPub\Verb\CreateNote; class ProfileOutbox extends Fractal\TransformerAbstract { + protected $defaultIncludes = ['orderedItems']; + public function transform(Profile $profile) { - $count = $profile->statuses()->count(); - $statuses = $profile->statuses()->has('media')->orderBy('id', 'desc')->take(20)->get()->map(function ($i, $k) { - $item = [ - 'id' => $i->permalink(), - // TODO: handle other types - 'type' => 'Create', - 'actor' => $i->profile->url(), - 'published' => $i->created_at->toISO8601String(), - 'to' => [ - 'https://www.w3.org/ns/activitystreams#Public', - ], - 'cc' => [ - $i->profile->permalink('/followers'), - ], - 'object' => [ - 'id' => $i->url(), - - // TODO: handle other types - 'type' => 'Note', - - // XXX: CW Title - 'summary' => null, - 'content' => $i->rendered ?? $i->caption, - 'inReplyTo' => null, - - // TODO: fix date format - 'published' => $i->created_at->toAtomString(), - 'url' => $i->url(), - 'attributedTo' => $i->profile->permalink(), - 'to' => [ - // TODO: handle proper scope - 'https://www.w3.org/ns/activitystreams#Public', - ], - 'cc' => [ - // TODO: add cc's - //"{$notice->getProfile()->getUrl()}/subscribers", - ], - 'sensitive' => (bool) $i->is_nsfw, - 'atomUri' => $i->url(), - 'inReplyToAtomUri' => null, - 'attachment' => [ - - // TODO: support more than 1 attachment - [ - 'type' => 'Document', - 'mediaType' => $i->firstMedia()->mime, - 'url' => $i->firstMedia()->url(), - 'name' => null, - ], - ], - 'tag' => [], - ], - ]; - - return $item; - }); + $count = $profile->statuses()->whereHas('media')->count(); return [ '@context' => 'https://www.w3.org/ns/activitystreams', 'id' => $profile->permalink('/outbox'), 'type' => 'OrderedCollection', 'totalItems' => $count, - 'orderedItems' => $statuses, ]; } + + public function includeOrderedItems(Profile $profile) + { + $statuses = $profile + ->statuses() + ->with('media') + ->whereVisibility('public') + ->orderBy('created_at', 'desc') + ->paginate(10); + + return $this->collection($statuses, new CreateNote); + } } From e45853166d3d9b857a50940d2650a7369960dc1c Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 15 Dec 2018 01:16:22 -0700 Subject: [PATCH 6/7] Update vue components --- app/Http/Controllers/FederationController.php | 12 +++++++++--- resources/assets/js/components/PostComments.vue | 3 +-- resources/assets/js/components/Timeline.vue | 10 +++++----- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/FederationController.php b/app/Http/Controllers/FederationController.php index ea119d077..aaba0cc4d 100644 --- a/app/Http/Controllers/FederationController.php +++ b/app/Http/Controllers/FederationController.php @@ -167,7 +167,7 @@ XML; public function userInbox(Request $request, $username) { - // todo + return; } public function userFollowing(Request $request, $username) @@ -175,7 +175,10 @@ XML; if (config('pixelfed.activitypub_enabled') == false) { abort(403); } - $profile = Profile::whereNull('remote_url')->whereUsername($username)->firstOrFail(); + $profile = Profile::whereNull('remote_url') + ->whereUsername($username) + ->whereIsPrivate(false) + ->firstOrFail(); $obj = [ '@context' => 'https://www.w3.org/ns/activitystreams', 'id' => $request->getUri(), @@ -193,7 +196,10 @@ XML; if (config('pixelfed.activitypub_enabled') == false) { abort(403); } - $profile = Profile::whereNull('remote_url')->whereUsername($username)->firstOrFail(); + $profile = Profile::whereNull('remote_url') + ->whereUsername($username) + ->whereIsPrivate(false) + ->firstOrFail(); $obj = [ '@context' => 'https://www.w3.org/ns/activitystreams', 'id' => $request->getUri(), diff --git a/resources/assets/js/components/PostComments.vue b/resources/assets/js/components/PostComments.vue index 5ac700c1e..cc57ad699 100644 --- a/resources/assets/js/components/PostComments.vue +++ b/resources/assets/js/components/PostComments.vue @@ -3,7 +3,6 @@ font-size: 14px; } .comment-text { - word-break: break-all; } .comment-text p { display: inline; @@ -33,7 +32,7 @@ Reply Permalink - Embed + Profile Report diff --git a/resources/assets/js/components/Timeline.vue b/resources/assets/js/components/Timeline.vue index 450414f36..818691161 100644 --- a/resources/assets/js/components/Timeline.vue +++ b/resources/assets/js/components/Timeline.vue @@ -41,13 +41,13 @@

{{ status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media'}}

(click to show)

- +
-
+
@@ -74,7 +74,7 @@
-
+
@@ -251,7 +251,7 @@
- avatar + avatar

@{{profile.username}}

@@ -291,7 +291,7 @@
- +

From e69b58664c3e40c517c686d74d041e042439ac53 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 15 Dec 2018 01:18:13 -0700 Subject: [PATCH 7/7] Bump version --- config/pixelfed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/pixelfed.php b/config/pixelfed.php index f5167a088..51e20bf4f 100644 --- a/config/pixelfed.php +++ b/config/pixelfed.php @@ -23,7 +23,7 @@ return [ | This value is the version of your PixelFed instance. | */ - 'version' => '0.5.4', + 'version' => '0.5.5', /* |--------------------------------------------------------------------------