Update StatusController, add shortcodeRedirect method

This commit is contained in:
Daniel Supernault 2020-07-20 08:32:16 -06:00
parent a327f5c167
commit f34977d9a8
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -17,6 +17,7 @@ use Illuminate\Http\Request;
use League\Fractal; use League\Fractal;
use App\Util\Media\Filter; use App\Util\Media\Filter;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use App\Services\HashidService;
class StatusController extends Controller class StatusController extends Controller
{ {
@ -65,6 +66,16 @@ class StatusController extends Controller
return view($template, compact('user', 'status')); 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) public function showId(int $id)
{ {
abort(404); abort(404);