mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-22 23:09:41 +00:00
Update CommentController, prepare for Micro UI
This commit is contained in:
parent
0c1eff85d2
commit
dc2a012e6e
1 changed files with 20 additions and 3 deletions
|
@ -2,13 +2,18 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Auth;
|
||||||
|
|
||||||
use App\Comment;
|
use App\Comment;
|
||||||
use App\Jobs\CommentPipeline\CommentPipeline;
|
use App\Jobs\CommentPipeline\CommentPipeline;
|
||||||
use App\Jobs\StatusPipeline\NewStatusPipeline;
|
use App\Jobs\StatusPipeline\NewStatusPipeline;
|
||||||
use App\Profile;
|
use App\Profile;
|
||||||
use App\Status;
|
use App\Status;
|
||||||
use Auth;
|
use League\Fractal;
|
||||||
use Illuminate\Http\Request;
|
use App\Transformer\Api\StatusTransformer;
|
||||||
|
use League\Fractal\Serializer\ArraySerializer;
|
||||||
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
|
|
||||||
class CommentController extends Controller
|
class CommentController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -57,7 +62,19 @@ class CommentController extends Controller
|
||||||
CommentPipeline::dispatch($status, $reply);
|
CommentPipeline::dispatch($status, $reply);
|
||||||
|
|
||||||
if ($request->ajax()) {
|
if ($request->ajax()) {
|
||||||
$response = ['code' => 200, 'msg' => 'Comment saved', 'username' => $profile->username, 'url' => $reply->url(), 'profile' => $profile->url(), 'comment' => $reply->caption];
|
$fractal = new Fractal\Manager();
|
||||||
|
$fractal->setSerializer(new ArraySerializer());
|
||||||
|
$entity = new Fractal\Resource\Item($reply, new StatusTransformer());
|
||||||
|
$entity = $fractal->createData($entity)->toArray();
|
||||||
|
$response = [
|
||||||
|
'code' => 200,
|
||||||
|
'msg' => 'Comment saved',
|
||||||
|
'username' => $profile->username,
|
||||||
|
'url' => $reply->url(),
|
||||||
|
'profile' => $profile->url(),
|
||||||
|
'comment' => $reply->caption,
|
||||||
|
'entity' => $entity,
|
||||||
|
];
|
||||||
} else {
|
} else {
|
||||||
$response = redirect($status->url());
|
$response = redirect($status->url());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue