1
0
Fork 0
forked from mirror/pixelfed

Update CommentController, remove hashids

This commit is contained in:
Daniel Supernault 2018-05-26 16:46:07 -06:00
parent 43c9c264ef
commit befa82dc04

View file

@ -3,9 +3,9 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth;
use App\Jobs\StatusPipeline\NewStatusPipeline;
use Auth, Hashids;
use App\{Comment, Profile, Status};
use Vinkla\Hashids\Facades\Hashids;
class CommentController extends Controller
{
@ -13,29 +13,25 @@ class CommentController extends Controller
{
if(Auth::check() === false) { abort(403); }
$this->validate($request, [
'item' => 'required|alpha_num',
'item' => 'required|integer',
'comment' => 'required|string|max:500'
]);
try {
$statusId = Hashids::decode($request->item)[0];
} catch (Exception $e) {
abort(500);
}
$comment = $request->input('comment');
$statusId = $request->item;
$user = Auth::user();
$profile = $user->profile;
$status = Status::findOrFail($statusId);
$comment = new Comment;
$comment->profile_id = $profile->id;
$comment->user_id = $user->id;
$comment->status_id = $status->id;
$comment->comment = e($request->comment);
$comment->rendered = e($request->comment);
$comment->is_remote = false;
$comment->entities = null;
$comment->save();
$reply = new Status();
$reply->profile_id = $profile->id;
$reply->caption = $comment;
$reply->rendered = $comment;
$reply->in_reply_to_id = $status->id;
$reply->in_reply_to_profile_id = $status->profile_id;
$reply->save();
NewStatusPipeline::dispatch($reply, false);
return redirect($status->url());
}