1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-23 08:14:10 +00:00

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