From 1c20d6960aa61f36293989a4afd175f510edb30f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 17 Jan 2022 17:11:16 -0700 Subject: [PATCH 1/2] Update MediaStorageService, fix reremote avatar bug --- app/Jobs/StatusPipeline/StatusDelete.php | 14 ++++------- app/Jobs/StatusPipeline/StatusEntityLexer.php | 14 ++++------- app/Services/MediaStorageService.php | 25 +++++++++++++------ 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/app/Jobs/StatusPipeline/StatusDelete.php b/app/Jobs/StatusPipeline/StatusDelete.php index f78d9b009..7ae3a822a 100644 --- a/app/Jobs/StatusPipeline/StatusDelete.php +++ b/app/Jobs/StatusPipeline/StatusDelete.php @@ -61,16 +61,12 @@ class StatusDelete implements ShouldQueue $status = $this->status; $profile = $this->status->profile; - StatusService::del($status->id); - $count = $profile->statuses() - ->getQuery() - ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) - ->whereNull('in_reply_to_id') - ->whereNull('reblog_of_id') - ->count(); + StatusService::del($status->id, true); - $profile->status_count = ($count - 1); - $profile->save(); + if(in_array($status->type, ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])) { + $profile->status_count = $profile->status_count - 1; + $profile->save(); + } if(config_cache('federation.activitypub.enabled') == true) { $this->fanoutDelete($status); diff --git a/app/Jobs/StatusPipeline/StatusEntityLexer.php b/app/Jobs/StatusPipeline/StatusEntityLexer.php index 1c5b172b6..b0ef84ee6 100644 --- a/app/Jobs/StatusPipeline/StatusEntityLexer.php +++ b/app/Jobs/StatusPipeline/StatusEntityLexer.php @@ -52,16 +52,12 @@ class StatusEntityLexer implements ShouldQueue public function handle() { $profile = $this->status->profile; + $status = $this->status; - $count = $profile->statuses() - ->getQuery() - ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) - ->whereNull('in_reply_to_id') - ->whereNull('reblog_of_id') - ->count(); - - $profile->status_count = $count; - $profile->save(); + if(in_array($status->type, ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])) { + $profile->status_count = $profile->status_count + 1; + $profile->save(); + } if($profile->no_autolink == false) { $this->parseEntities(); diff --git a/app/Services/MediaStorageService.php b/app/Services/MediaStorageService.php index 5d58ee077..e252aacf6 100644 --- a/app/Services/MediaStorageService.php +++ b/app/Services/MediaStorageService.php @@ -43,16 +43,25 @@ class MediaStorageService { $h = $r->getHeaders(); - if (isset($h['Content-Length'], $h['Content-Type']) == false) { - return false; + 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(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($len < 10 || $len > ((config_cache('pixelfed.max_photo_size') * 1000))) { return false; From 207742479ce4c2f6d87d73bafc960dd55fe9df0b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 17 Jan 2022 17:12:15 -0700 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95961790d..06807ca53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.11.2...dev) +### Updated +- Updated MediaStorageService, fix remote avatar bug. ([1c20d696](https://github.com/pixelfed/pixelfed/commit/1c20d696)) + ## [v0.11.2 (2022-01-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.1...v0.11.2) ### Breaking