From f34977d9a8e73aa8a8fc8886354ec9fcbae7a564 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 20 Jul 2020 08:32:16 -0600 Subject: [PATCH] Update StatusController, add shortcodeRedirect method --- app/Http/Controllers/StatusController.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index cf209bf15..5ec19aa25 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -17,6 +17,7 @@ use Illuminate\Http\Request; use League\Fractal; use App\Util\Media\Filter; use Illuminate\Support\Str; +use App\Services\HashidService; class StatusController extends Controller { @@ -65,6 +66,16 @@ class StatusController extends Controller return view($template, compact('user', 'status')); } + public function shortcodeRedirect(Request $request, $id) + { + if(strlen($id) < 5 || !Auth::check()) { + return redirect('/login?next='.urlencode('/' . $request->path())); + } + $id = HashidService::decode($id); + $status = Status::findOrFail($id); + return redirect($status->url()); + } + public function showId(int $id) { abort(404);