mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-26 16:23:16 +00:00
Update PublicApiController, add state endpoint
This commit is contained in:
parent
cc515c1771
commit
9fc5a80cd3
1 changed files with 33 additions and 18 deletions
|
@ -92,6 +92,25 @@ class PublicApiController extends Controller
|
||||||
$item = new Fractal\Resource\Item($status, new StatusStatelessTransformer());
|
$item = new Fractal\Resource\Item($status, new StatusStatelessTransformer());
|
||||||
$res = [
|
$res = [
|
||||||
'status' => $this->fractal->createData($item)->toArray(),
|
'status' => $this->fractal->createData($item)->toArray(),
|
||||||
|
];
|
||||||
|
return $res;
|
||||||
|
});
|
||||||
|
return response()->json($res);
|
||||||
|
}
|
||||||
|
$item = new Fractal\Resource\Item($status, new StatusStatelessTransformer());
|
||||||
|
$res = [
|
||||||
|
'status' => $this->fractal->createData($item)->toArray(),
|
||||||
|
];
|
||||||
|
return response()->json($res);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function statusState(Request $request, $username, int $postid)
|
||||||
|
{
|
||||||
|
$profile = Profile::whereUsername($username)->whereNull('status')->firstOrFail();
|
||||||
|
$status = Status::whereProfileId($profile->id)->findOrFail($postid);
|
||||||
|
$this->scopeCheck($profile, $status);
|
||||||
|
if(!Auth::check()) {
|
||||||
|
$res = [
|
||||||
'user' => [],
|
'user' => [],
|
||||||
'likes' => [],
|
'likes' => [],
|
||||||
'shares' => [],
|
'shares' => [],
|
||||||
|
@ -101,23 +120,19 @@ class PublicApiController extends Controller
|
||||||
'bookmarked' => false,
|
'bookmarked' => false,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
return response()->json($res, 200, [], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|
return response()->json($res);
|
||||||
});
|
|
||||||
return $res;
|
|
||||||
}
|
}
|
||||||
$item = new Fractal\Resource\Item($status, new StatusTransformer());
|
|
||||||
$res = [
|
$res = [
|
||||||
'status' => $this->fractal->createData($item)->toArray(),
|
|
||||||
'user' => $this->getUserData($request->user()),
|
'user' => $this->getUserData($request->user()),
|
||||||
'likes' => $this->getLikes($status),
|
'likes' => [],
|
||||||
'shares' => $this->getShares($status),
|
'shares' => [],
|
||||||
'reactions' => [
|
'reactions' => [
|
||||||
'liked' => $status->liked(),
|
'liked' => (bool) $status->liked(),
|
||||||
'shared' => $status->shared(),
|
'shared' => (bool) $status->shared(),
|
||||||
'bookmarked' => $status->bookmarked(),
|
'bookmarked' => (bool) $status->bookmarked(),
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
return response()->json($res, 200, [], JSON_PRETTY_PRINT);
|
return response()->json($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function statusComments(Request $request, $username, int $postId)
|
public function statusComments(Request $request, $username, int $postId)
|
||||||
|
|
Loading…
Reference in a new issue