From 3bd211d7f5848f243a1d83f6696aa8ef2489ecf6 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 23 Jan 2022 01:47:31 -0700 Subject: [PATCH 1/2] Update profile embeds, fix NaN bug and improve performance --- app/Http/Controllers/ProfileController.php | 11 ++-- resources/views/profile/embed.blade.php | 58 +++++++++++++--------- 2 files changed, 41 insertions(+), 28 deletions(-) diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index a3331c8d0..6657a290a 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -13,6 +13,7 @@ use App\Story; use App\User; use App\UserFilter; use League\Fractal; +use App\Services\AccountService; use App\Services\FollowerService; use App\Util\Lexer\Nickname; use App\Util\Webfinger\Webfinger; @@ -55,7 +56,6 @@ class ProfileController extends Controller $owner = false; $is_following = false; - $is_admin = $user->user->is_admin; $profile = $user; $settings = [ 'crawlable' => $settings->crawlable, @@ -227,11 +227,12 @@ class ProfileController extends Controller return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']); } - $content = Cache::remember('profile:embed:'.$profile->id, now()->addHours(12), function() use($profile) { - return View::make('profile.embed')->with(compact('profile'))->render(); - }); + if(AccountService::canEmbed($profile->user_id) == false) { + return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']); + } - return response($content)->withHeaders(['X-Frame-Options' => 'ALLOWALL']); + $profile = AccountService::get($profile->id); + return view('profile.embed', compact('profile'))->withHeaders(['X-Frame-Options' => 'ALLOWALL']); } public function stories(Request $request, $username) diff --git a/resources/views/profile/embed.blade.php b/resources/views/profile/embed.blade.php index caf3fd3df..4850f41f5 100644 --- a/resources/views/profile/embed.blade.php +++ b/resources/views/profile/embed.blade.php @@ -12,7 +12,7 @@ - + @@ -37,9 +37,9 @@
- - - {{$profile->username}} + + + {{$profile['username']}}
@@ -50,35 +50,22 @@
-

{{$profile->statuses()->count()}}

+

Posts

-

{{$profile->followerCount(true)}}

+

Followers

-
- @foreach($profile->statuses()->latest()->whereScope('public')->whereIsNsfw(false)->has('media')->whereType('photo')->take(9)->get() as $post) - - @endforeach -
+
@@ -90,8 +77,33 @@ + From 97a75e0fde1e921eaed80f19f689d4d15ad0cf2d Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 23 Jan 2022 01:48:03 -0700 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dca6c722..cf294eb62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Updated MediaStorageService, fix remote avatar bug. ([1c20d696](https://github.com/pixelfed/pixelfed/commit/1c20d696)) - Updated WebfingerService. Fixes #3167. ([aff74566](https://github.com/pixelfed/pixelfed/commit/aff74566)) - Updated ComposeModal, add max file size and allowed mime types. Fixes #3162. ([879281cc](https://github.com/pixelfed/pixelfed/commit/879281cc)) +- Updated profile embeds, fix NaN bug and improve performance. ([3bd211d7](https://github.com/pixelfed/pixelfed/commit/3bd211d7)) ## [v0.11.2 (2022-01-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.1...v0.11.2)