From 467c9d754ee156d9fc49ab105ff3e23f32ce677f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 18 Mar 2023 21:45:35 -0600 Subject: [PATCH] Update atom feed, improve cache expiry and fix double encoding bug. Fixes #4121 --- app/Http/Controllers/ProfileController.php | 2 +- app/Jobs/StatusPipeline/StatusDelete.php | 4 +++- app/Jobs/StatusPipeline/StatusEntityLexer.php | 3 +++ resources/views/atom/user.blade.php | 6 ++++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 3f6795d5b..d092d349b 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -207,7 +207,7 @@ class ProfileController extends Controller abort_if(!$profile || $profile['locked'] || !$profile['local'], 404); - $data = Cache::remember('pf:atom:user-feed:by-id:' . $profile['id'], 86400, function() use($pid, $profile) { + $data = Cache::remember('pf:atom:user-feed:by-id:' . $profile['id'], 43200, function() use($pid, $profile) { $items = DB::table('statuses') ->whereProfileId($pid) ->whereVisibility('public') diff --git a/app/Jobs/StatusPipeline/StatusDelete.php b/app/Jobs/StatusPipeline/StatusDelete.php index d7f237e20..0a0721648 100644 --- a/app/Jobs/StatusPipeline/StatusDelete.php +++ b/app/Jobs/StatusPipeline/StatusDelete.php @@ -2,7 +2,7 @@ namespace App\Jobs\StatusPipeline; -use DB, Storage; +use DB, Cache, Storage; use App\{ AccountInterstitial, Bookmark, @@ -81,6 +81,8 @@ class StatusDelete implements ShouldQueue } } + Cache::forget('pf:atom:user-feed:by-id:' . $status->profile_id); + if(config_cache('federation.activitypub.enabled') == true) { return $this->fanoutDelete($status); } else { diff --git a/app/Jobs/StatusPipeline/StatusEntityLexer.php b/app/Jobs/StatusPipeline/StatusEntityLexer.php index 591a06604..1ee57c559 100644 --- a/app/Jobs/StatusPipeline/StatusEntityLexer.php +++ b/app/Jobs/StatusPipeline/StatusEntityLexer.php @@ -12,6 +12,7 @@ use App\Services\PublicTimelineService; use App\Util\Lexer\Autolink; use App\Util\Lexer\Extractor; use App\Util\Sentiment\Bouncer; +use Cache; use DB; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; @@ -166,6 +167,8 @@ class StatusEntityLexer implements ShouldQueue if(config_cache('pixelfed.bouncer.enabled')) { Bouncer::get($status); } + + Cache::forget('pf:atom:user-feed:by-id:' . $status->profile_id); $hideNsfw = config('instance.hide_nsfw_on_public_feeds'); if( $status->uri == null && $status->scope == 'public' && diff --git a/resources/views/atom/user.blade.php b/resources/views/atom/user.blade.php index b6f7cb4e8..0b7595ddf 100644 --- a/resources/views/atom/user.blade.php +++ b/resources/views/atom/user.blade.php @@ -24,12 +24,14 @@ iteration}}" src="{{ $item['media_attachments'][0]['url'] }}" alt="{{ $item['media_attachments'][0]['description'] }}"> -

{{ $item['content'] }}

+ {{ $item['media_attachments'][0]['description'] }} +

{!! $item['content'] !!}

]]>
+ @if($item['content'] && strlen($item['content'])) {{ $item['content'] }} + @endif @endforeach