forked from mirror/pixelfed
Update CommentController, remove hashids
This commit is contained in:
parent
43c9c264ef
commit
befa82dc04
1 changed files with 14 additions and 18 deletions
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue