From f5701e87146fd1aa442a52e353960eed2a25f744 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 24 Jul 2019 19:04:39 -0600 Subject: [PATCH 1/6] Update Inbox --- app/Util/ActivityPub/Inbox.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Util/ActivityPub/Inbox.php b/app/Util/ActivityPub/Inbox.php index 7c2f2332b..001cfd86e 100644 --- a/app/Util/ActivityPub/Inbox.php +++ b/app/Util/ActivityPub/Inbox.php @@ -243,6 +243,8 @@ class Inbox public function handleAcceptActivity() { + return; + $actor = $this->payload['actor']; $obj = $this->payload['object']; switch ($obj['type']) { From 5f03dfa05baab283aeadd44e645bee5b60ae37d3 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 24 Jul 2019 19:25:26 -0600 Subject: [PATCH 2/6] Update AP Helpers --- app/Util/ActivityPub/Helpers.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Util/ActivityPub/Helpers.php b/app/Util/ActivityPub/Helpers.php index e9ea90e91..e0fb72995 100644 --- a/app/Util/ActivityPub/Helpers.php +++ b/app/Util/ActivityPub/Helpers.php @@ -388,7 +388,10 @@ class Helpers { if($local == true) { $id = last(explode('/', $url)); - return Profile::whereUsername($id)->firstOrFail(); + return Profile::whereNull('status') + ->whereNull('domain') + ->whereUsername($id) + ->firstOrFail(); } $res = self::fetchProfileFromUrl($url); if(isset($res['id']) == false) { From ad4a36affd76fce0de68e492b8b0268d346f53b8 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 24 Jul 2019 19:25:51 -0600 Subject: [PATCH 3/6] Update Inbox, handle Accept.Follow --- app/Util/ActivityPub/Inbox.php | 53 ++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/app/Util/ActivityPub/Inbox.php b/app/Util/ActivityPub/Inbox.php index 001cfd86e..b51f3102a 100644 --- a/app/Util/ActivityPub/Inbox.php +++ b/app/Util/ActivityPub/Inbox.php @@ -15,6 +15,7 @@ use App\{ use Carbon\Carbon; use App\Util\ActivityPub\Helpers; use App\Jobs\LikePipeline\LikePipeline; +use App\Jobs\FollowPipeline\FollowPipeline; use App\Util\ActivityPub\Validator\{ Accept, @@ -243,30 +244,40 @@ class Inbox public function handleAcceptActivity() { - return; - + $actor = $this->payload['actor']; $obj = $this->payload['object']; - switch ($obj['type']) { - case 'Follow': - $accept = [ - '@context' => 'https://www.w3.org/ns/activitystreams', - 'id' => $target->permalink().'#accepts/follows/' . $follower->id, - 'type' => 'Accept', - 'actor' => $target->permalink(), - 'object' => [ - 'id' => $actor->permalink('#follows/'.$target->id), - 'type' => 'Follow', - 'actor' => $actor->permalink(), - 'object' => $target->permalink() - ] - ]; - break; - - default: - # code... - break; + $type = $this->payload['object']['type']; + + if($type !== 'Follow') { + return; } + + $actor = Helpers::validateUrl($actor); + $target = Helpers::validateLocalUrl($obj); + + if(!$actor || !$target) { + return; + } + $actor = Helpers::profileFetch($actor); + $target = Helpers::profileFetch($target); + + $request = FollowRequest::whereFollowerId($actor->id) + ->whereFollowingId($target->id) + ->whereIsRejected(false) + ->first(); + + if(!$request) { + return; + } + + $follower = new Follower(); + $follower->profile_id = $actor->id; + $follower->following_id = $target->id; + $follower->save(); + FollowPipeline::dispatch($follower); + + $request->delete(); } public function handleDeleteActivity() From 00047e9b1b243c11a2499c99eccca2edeae32a66 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 24 Jul 2019 19:32:07 -0600 Subject: [PATCH 4/6] Update Inbox --- app/Util/ActivityPub/Inbox.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Util/ActivityPub/Inbox.php b/app/Util/ActivityPub/Inbox.php index b51f3102a..b64985bf6 100644 --- a/app/Util/ActivityPub/Inbox.php +++ b/app/Util/ActivityPub/Inbox.php @@ -246,7 +246,7 @@ class Inbox { $actor = $this->payload['actor']; - $obj = $this->payload['object']; + $obj = $this->payload['object']['object']; $type = $this->payload['object']['type']; if($type !== 'Follow') { From 536e41507ad8a26cc0f4b20fc4efb380f1f12b82 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 24 Jul 2019 22:24:27 -0600 Subject: [PATCH 5/6] Update media command --- .../Commands/CatchUnoptimizedMedia.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/CatchUnoptimizedMedia.php b/app/Console/Commands/CatchUnoptimizedMedia.php index 22ae56be1..1072c45d6 100644 --- a/app/Console/Commands/CatchUnoptimizedMedia.php +++ b/app/Console/Commands/CatchUnoptimizedMedia.php @@ -2,6 +2,7 @@ namespace App\Console\Commands; +use DB; use App\Jobs\ImageOptimizePipeline\ImageOptimize; use App\Media; use Illuminate\Console\Command; @@ -39,9 +40,19 @@ class CatchUnoptimizedMedia extends Command */ public function handle() { - $medias = Media::whereNotNull('status_id')->whereNull('processed_at')->take(250)->get(); - foreach ($medias as $media) { - ImageOptimize::dispatch($media); - } + DB::transaction(function() { + Media::whereNull('processed_at') + ->whereNotNull('status_id') + ->whereNotNull('media_path') + ->whereIn('mime', [ + 'image/jpeg', + 'image/png', + ]) + ->chunk(50, function($medias) { + foreach ($medias as $media) { + ImageOptimize::dispatch($media); + } + }); + }); } } From afddd0bcb392427136b42275e930fdc65d443b8c Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 26 Jul 2019 20:19:20 -0600 Subject: [PATCH 6/6] Fixes #1550 --- resources/views/collection/show.blade.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/resources/views/collection/show.blade.php b/resources/views/collection/show.blade.php index 17b8fa63b..76e1fce1f 100644 --- a/resources/views/collection/show.blade.php +++ b/resources/views/collection/show.blade.php @@ -8,6 +8,17 @@

Collection

{{$collection->title}}

+ @auth + @if($collection->profile_id == Auth::user()->profile_id) +
+
+ @csrf + + +
+
+ @endif + @endauth