diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index 7327cc0a4..f8e37a296 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -76,13 +76,23 @@ class StatusController extends Controller public function showEmbed(Request $request, $username, int $id) { - abort(404); - $profile = Profile::whereNull('status')->whereUsername($username)->first(); - $status = Status::whereProfileId($profile->id)->whereScope('public')->find($id); - if(!$profile || !$status) { + $profile = Profile::whereNull(['domain','status'])->whereUsername($username)->first(); + if(!$profile) { return view('status.embed-removed'); } - return view('status.embed', compact('status')); + $status = Status::whereProfileId($profile->id) + ->whereNull('uri') + ->whereScope('public') + ->whereIsNsfw(false) + ->whereIn('type', ['photo', 'video']) + ->find($id); + if(!$status) { + return view('status.embed-removed'); + } + $showLikes = $request->filled('likes') && $request->likes == true; + $showCaption = $request->filled('caption') && $request->caption !== false; + $layout = $request->filled('layout') && $request->layout == 'compact' ? 'compact' : 'full'; + return view('status.embed', compact('status', 'showLikes', 'showCaption', 'layout')); } public function showObject(Request $request, $username, int $id) diff --git a/public/embed.js b/public/embed.js new file mode 100644 index 000000000..5acc20efe --- /dev/null +++ b/public/embed.js @@ -0,0 +1 @@ +!function(){var e;e=function(){var e=[];window.addEventListener("message",function(t){var n=t.data||{};"setHeight"===n.type&&e[n.id]&&(e[n.id].height=n.height)}),[].forEach.call(document.querySelectorAll("iframe.pixelfed__embed"),function(t){t.scrolling="no",t.style.overflow="hidden",e.push(t);var n=e.length-1;t.onload=function(){t.contentWindow.postMessage({type:"setHeight",id:n},"*")},t.onload()})},-1!==["interactive","complete"].indexOf(document.readyState)?e():document.addEventListener("DOMContentLoaded",e)}(); \ No newline at end of file diff --git a/resources/views/status/embed-removed.blade.php b/resources/views/status/embed-removed.blade.php new file mode 100644 index 000000000..3e147ec89 --- /dev/null +++ b/resources/views/status/embed-removed.blade.php @@ -0,0 +1,46 @@ + + +
+ + + + + + +