Add Profile Embeds

This commit is contained in:
Daniel Supernault 2019-12-04 21:21:08 -07:00
parent b793f9c4bb
commit fb7a3cf0e4
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
4 changed files with 174 additions and 0 deletions

View file

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth;
use Cache;
use View;
use App\Follower;
use App\FollowRequest;
use App\Profile;
@ -189,4 +190,29 @@ class ProfileController extends Controller
abort_if(!Auth::check(), 404);
return redirect(Auth::user()->url());
}
public function embed(Request $request, $username)
{
$res = view('profile.embed-removed');
if(strlen($username) > 15 || strlen($username) < 2) {
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
}
$profile = Profile::whereUsername($username)
->whereIsPrivate(false)
->whereNull('status')
->whereNull('domain')
->first();
if(!$profile) {
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();
});
return response($content)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
}
}