From 3590adbd875ebf943b614090e12f6d51c55e8e11 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 16 Jul 2023 04:17:23 -0600 Subject: [PATCH 1/5] Update MediaStorageService, improve head header handling --- app/Services/MediaStorageService.php | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/app/Services/MediaStorageService.php b/app/Services/MediaStorageService.php index fd70e3a0f..b52662d1f 100644 --- a/app/Services/MediaStorageService.php +++ b/app/Services/MediaStorageService.php @@ -16,6 +16,7 @@ use App\Services\AccountService; use App\Http\Controllers\AvatarController; use GuzzleHttp\Exception\RequestException; use App\Jobs\MediaPipeline\MediaDeletePipeline; +use Illuminate\Support\Arr; class MediaStorageService { @@ -42,27 +43,16 @@ class MediaStorageService { return false; } - $h = $r->getHeaders(); + $h = Arr::mapWithKeys($r->getHeaders(), function($item, $key) { + return [strtolower($key) => last($item)]; + }); - if (isset($h['content-length']) && isset($h['content-type'])) { - if(empty($h['content-length']) || empty($h['content-type'])) { - return false; - } - $len = is_array($h['content-length']) ? $h['content-length'][0] : $h['content-length']; - $mime = is_array($h['content-type']) ? $h['content-type'][0] : $h['content-type']; - } else { - if (isset($h['Content-Length'], $h['Content-Type']) == false) { - return false; - } - - if(empty($h['Content-Length']) || empty($h['Content-Type']) ) { - return false; - } - - $len = is_array($h['Content-Length']) ? $h['Content-Length'][0] : $h['Content-Length']; - $mime = is_array($h['Content-Type']) ? $h['Content-Type'][0] : $h['Content-Type']; - } + if(!isset($h['content-length'], $h['content-type'])) { + return false; + } + $len = (int) $h['content-length']; + $mime = $h['content-type']; if($len < 10 || $len > ((config_cache('pixelfed.max_photo_size') * 1000))) { return false; From ff2c16fe745c97f5a9d7cf4bfa23eded6a898743 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 16 Jul 2023 04:23:41 -0600 Subject: [PATCH 2/5] Update admin user view, improve previews --- resources/views/admin/users/show.blade.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/resources/views/admin/users/show.blade.php b/resources/views/admin/users/show.blade.php index 1a482467e..f55c1dac3 100644 --- a/resources/views/admin/users/show.blade.php +++ b/resources/views/admin/users/show.blade.php @@ -140,10 +140,15 @@

Recent Posts


- @foreach($profile->statuses()->whereHas('media')->latest()->take(9)->get() as $item) -
+ @foreach($profile->statuses()->whereHas('media')->latest()->take(16)->get() as $item) + @php($post = \App\Services\StatusService::get($item->id, false)) + @endforeach From 7a431af93ab89377cf3c6039f5932f0afbb98bd4 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 16 Jul 2023 04:24:58 -0600 Subject: [PATCH 3/5] Update Media model --- app/Media.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Media.php b/app/Media.php index 16448dbbf..b3f9ccba0 100644 --- a/app/Media.php +++ b/app/Media.php @@ -20,8 +20,8 @@ class Media extends Model protected $guarded = []; protected $casts = [ - 'srcset' => 'array', - 'deleted_at' => 'datetime' + 'srcset' => 'array', + 'deleted_at' => 'datetime' ]; public function status() @@ -63,7 +63,7 @@ class Media extends Model } if($this->media_path && $this->mime && in_array($this->mime, ['image/jpeg', 'image/png'])) { - return $this->remote_media || Str::startsWith($this->media_path, 'http') ? + return $this->remote_media || Str::startsWith($this->media_path, 'http') ? $this->media_path : url(Storage::url($this->media_path)); } @@ -78,6 +78,9 @@ class Media extends Model public function mimeType() { + if(!$this->mime) { + return; + } return explode('/', $this->mime)[0]; } From 0d802c313b10f575cfe9a9ebe74a6b53e68a768c Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 16 Jul 2023 04:27:14 -0600 Subject: [PATCH 4/5] Update FanoutDeletePipeline, fix AP object --- app/Jobs/DeletePipeline/FanoutDeletePipeline.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Jobs/DeletePipeline/FanoutDeletePipeline.php b/app/Jobs/DeletePipeline/FanoutDeletePipeline.php index a5ee65ac3..0ccb9d5c4 100644 --- a/app/Jobs/DeletePipeline/FanoutDeletePipeline.php +++ b/app/Jobs/DeletePipeline/FanoutDeletePipeline.php @@ -53,10 +53,10 @@ class FanoutDeletePipeline implements ShouldQueue "id" => $profile->permalink('#delete'), "type" => "Delete", "actor" => $profile->permalink(), - "to" => [ - "https://www.w3.org/ns/activitystreams#Public", + "object" => [ + "type" => "Person", + "id" => $profile->permalink() ], - "object" => $profile->permalink(), ]; $payload = json_encode($activity); From ce02f05718fee16dd7f44cc6072f06de25742cc2 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 16 Jul 2023 04:29:35 -0600 Subject: [PATCH 5/5] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e6807a2a..577337f93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,9 @@ - Update TransformImports command, increment status_count on profile model ([ba7551d8](https://github.com/pixelfed/pixelfed/commit/ba7551d8)) - Update AP Helpers, improve url validation and add optional dns verification, disabled by default ([2bef3e41](https://github.com/pixelfed/pixelfed/commit/2bef3e41)) - Update admin users blade view, show last_active_at and other info ([e0b48b29](https://github.com/pixelfed/pixelfed/commit/e0b48b29)) +- Update MediaStorageService, improve head header handling ([3590adbd](https://github.com/pixelfed/pixelfed/commit/3590adbd)) +- Update admin user view, improve previews ([ff2c16fe](https://github.com/pixelfed/pixelfed/commit/ff2c16fe)) +- Update FanoutDeletePipeline, fix AP object ([0d802c31](https://github.com/pixelfed/pixelfed/commit/0d802c31)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.8 (2023-05-29)](https://github.com/pixelfed/pixelfed/compare/v0.11.7...v0.11.8)