From c18dcde38ffa6a7fe8fcdbd36ffdca9a6661017f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 15 Aug 2022 22:29:07 -0600 Subject: [PATCH] Set Last-Modified header for atom feeds, fixes #2988 --- app/Http/Controllers/ProfileController.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 147d95842..179db033d 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -118,8 +118,7 @@ class ProfileController extends Controller 'list' => $settings->show_profile_followers ] ]; - $ui = $request->has('ui') && $request->input('ui') == 'memory' ? 'profile.memory' : 'profile.show'; - return view($ui, compact('profile', 'settings')); + return view('profile.show', compact('profile', 'settings')); } } @@ -210,7 +209,7 @@ class ProfileController extends Controller ->whereProfileId($pid) ->whereVisibility('public') ->whereType('photo') - ->latest() + ->orderByDesc('id') ->take(10) ->get() ->map(function($status) { @@ -224,10 +223,14 @@ class ProfileController extends Controller }) ->values(); $permalink = config('app.url') . "/users/{$profile['username']}.atom"; + $headers = ['Content-Type' => 'application/atom+xml']; + if($items && $items->count()) { + $headers['Last-Modified'] = now()->parse($items->first()['created_at'])->toRfc7231String(); + } return response() ->view('atom.user', compact('profile', 'items', 'permalink')) - ->header('Content-Type', 'application/atom+xml'); + ->withHeaders($headers); } public function meRedirect()