diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e75ba0c8..ea5f4ac9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,8 @@ - Update UnfollowPipeline, fix follower count cache bug ([6bdf73de](https://github.com/pixelfed/pixelfed/commit/6bdf73de)) - Update VideoPresenter component, add webkit-playsinline attribute to video element to prevent the full screen video player ([ad032916](https://github.com/pixelfed/pixelfed/commit/ad032916)) - Update VideoPlayer component, add playsinline attribute to video element ([8af23607](https://github.com/pixelfed/pixelfed/commit/8af23607)) +- Update StatusController, refactor status embeds ([9a7acc12](https://github.com/pixelfed/pixelfed/commit/9a7acc12)) +- Update ProfileController, refactor profile embeds ([8b8b1ffc](https://github.com/pixelfed/pixelfed/commit/8b8b1ffc)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.13 (2024-03-05)](https://github.com/pixelfed/pixelfed/compare/v0.11.12...v0.11.13) diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 65a756eaf..3fc877452 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -172,7 +172,7 @@ class ProfileController extends Controller $user = $this->getCachedUser($username); - abort_if(!$user, 404); + abort_if(! $user, 404); return redirect($user->url()); } @@ -254,7 +254,7 @@ class ProfileController extends Controller abort_if(! $profile || $profile['locked'] || ! $profile['local'], 404); - $aiCheck = Cache::remember('profile:ai-check:spam-login:'.$profile['id'], 86400, function () use ($profile) { + $aiCheck = Cache::remember('profile:ai-check:spam-login:'.$profile['id'], 3600, function () use ($profile) { $uid = User::whereProfileId($profile['id'])->first(); if (! $uid) { return true; @@ -348,7 +348,7 @@ class ProfileController extends Controller return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']); } - $aiCheck = Cache::remember('profile:ai-check:spam-login:'.$profile->id, 86400, function () use ($profile) { + $aiCheck = Cache::remember('profile:ai-check:spam-login:'.$profile->id, 3600, function () use ($profile) { $exists = AccountInterstitial::whereUserId($profile->user_id)->where('is_spam', 1)->count(); if ($exists) { return true; @@ -373,7 +373,7 @@ class ProfileController extends Controller public function stories(Request $request, $username) { - abort_if(!(bool) config_cache('instance.stories.enabled') || ! $request->user(), 404); + abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404); $profile = Profile::whereNull('domain')->whereUsername($username)->firstOrFail(); $pid = $profile->id; $authed = Auth::user()->profile_id; diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 7f77f9a81..e0864a4a7 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -8,6 +8,7 @@ use App\Jobs\SharePipeline\UndoSharePipeline; use App\Jobs\StatusPipeline\RemoteStatusDelete; use App\Jobs\StatusPipeline\StatusDelete; use App\Profile; +use App\Services\AccountService; use App\Services\HashidService; use App\Services\ReblogService; use App\Services\StatusService; @@ -113,19 +114,33 @@ class StatusController extends Controller return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']); } - $profile = Profile::whereNull(['domain', 'status']) - ->whereIsPrivate(false) - ->whereUsername($username) - ->first(); + $status = StatusService::get($id); - if (! $profile) { + if ( + ! $status || + ! isset($status['account'], $status['account']['id'], $status['local']) || + ! $status['local'] || + strtolower($status['account']['username']) !== strtolower($username) + ) { + $content = view('status.embed-removed'); + + return response($content, 404)->header('X-Frame-Options', 'ALLOWALL'); + } + + $profile = AccountService::get($status['account']['id'], true); + + if (! $profile || $profile['locked'] || ! $profile['local']) { $content = view('status.embed-removed'); return response($content)->header('X-Frame-Options', 'ALLOWALL'); } - $aiCheck = Cache::remember('profile:ai-check:spam-login:'.$profile->id, 86400, function () use ($profile) { - $exists = AccountInterstitial::whereUserId($profile->user_id)->where('is_spam', 1)->count(); + $aiCheck = Cache::remember('profile:ai-check:spam-login:'.$profile['id'], 3600, function () use ($profile) { + $user = Profile::find($profile['id']); + if (! $user) { + return true; + } + $exists = AccountInterstitial::whereUserId($user->user_id)->where('is_spam', 1)->count(); if ($exists) { return true; } @@ -138,17 +153,22 @@ class StatusController extends Controller return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']); } - $status = Status::whereProfileId($profile->id) - ->whereNull('uri') - ->whereScope('public') - ->whereIsNsfw(false) - ->whereIn('type', ['photo', 'video', 'photo:album']) - ->find($id); - if (! $status) { + + $status = StatusService::get($id); + + if ( + ! $status || + ! isset($status['account'], $status['account']['id']) || + intval($status['account']['id']) !== intval($profile['id']) || + $status['sensitive'] || + $status['visibility'] !== 'public' || + $status['pf_type'] !== 'photo' + ) { $content = view('status.embed-removed'); return response($content)->header('X-Frame-Options', 'ALLOWALL'); } + $showLikes = $request->filled('likes') && $request->likes == true; $showCaption = $request->filled('caption') && $request->caption !== false; $layout = $request->filled('layout') && $request->layout == 'compact' ? 'compact' : 'full'; diff --git a/resources/views/profile/embed.blade.php b/resources/views/profile/embed.blade.php index aeb6a5b99..71349994a 100644 --- a/resources/views/profile/embed.blade.php +++ b/resources/views/profile/embed.blade.php @@ -1,118 +1,96 @@ - - - + + - - {{ $title ?? config('app.name', 'Pixelfed') }} - + {{ $title ?? config_cache('app.name', 'Pixelfed') }} - + - - + -
-
-
-
- - - {{$profile['username']}} - -
-
- {{config('pixelfed.domain.app')}} - +
+
+ +
+
+
+

+

Posts

+
+
+

+

Followers

+
+
+

Follow

+
+
+
+
+ +
-
-
-
-
-

-

Posts

-
-
-

-

Followers

-
-
-

Follow

-
-
-
-
- -
-
- - - - - - - + diff --git a/resources/views/status/embed.blade.php b/resources/views/status/embed.blade.php index 54d9b7330..02ab2de90 100644 --- a/resources/views/status/embed.blade.php +++ b/resources/views/status/embed.blade.php @@ -1,172 +1,72 @@ - + - - - - - - - {{ $title ?? config('app.name', 'Pixelfed') }} - - - - - - - - - - - - + + + + + {{ $title ?? config_cache('app.name', 'Pixelfed') }} + + + + + + + + + + -
- @php($item = $status) -
- - - @php($status = $item) - @switch($status->viewType()) - @case('photo') - @case('image') - @if($status->is_nsfw) -
- -

CW / NSFW / Hidden Media

-

(click to show)

-
-
- - -
- @else -
- -
- @endif - @break - @case('photo:album') - - @break - @case('video') - @if($status->is_nsfw) -
- -

CW / NSFW / Hidden Media

-

(click to show)

-
-
- -
-
- @else -
- -
- @endif - @break - @case('video-album') - @if($status->is_nsfw) -
- -

CW / NSFW / Hidden Media

-

(click to show)

-
-
- -
-
- @else -
- -
- @endif - @break - @endswitch - - @if($layout != 'compact') -
- -
-
-

- - {{$item->profile->username}} - - @if($showCaption) - {!! $item->rendered ?? e($item->caption) !!} - @endif -

-
-
- @endif - -
-
- - - - - +
+
+ + +
+ +
+
+ @if($layout != 'compact') +
+ +
+
+

+ + {{$status['account']['username']}} + + @if($showCaption) + {{ $status['content_text'] }} + @endif +

+
+
+ @endif + +
+
+