mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-11 14:40:46 +00:00
Update PublicApiController
This commit is contained in:
parent
3109911887
commit
de49171027
1 changed files with 16 additions and 10 deletions
|
@ -43,6 +43,9 @@ class PublicApiController extends Controller
|
||||||
return [];
|
return [];
|
||||||
} else {
|
} else {
|
||||||
$profile = Auth::user()->profile;
|
$profile = Auth::user()->profile;
|
||||||
|
if($profile->status) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
$user = new Fractal\Resource\Item($profile, new AccountTransformer());
|
$user = new Fractal\Resource\Item($profile, new AccountTransformer());
|
||||||
return $this->fractal->createData($user)->toArray();
|
return $this->fractal->createData($user)->toArray();
|
||||||
}
|
}
|
||||||
|
@ -54,6 +57,9 @@ class PublicApiController extends Controller
|
||||||
return [];
|
return [];
|
||||||
} else {
|
} else {
|
||||||
$profile = Auth::user()->profile;
|
$profile = Auth::user()->profile;
|
||||||
|
if($profile->status) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
$likes = $status->likedBy()->orderBy('created_at','desc')->paginate(10);
|
$likes = $status->likedBy()->orderBy('created_at','desc')->paginate(10);
|
||||||
$collection = new Fractal\Resource\Collection($likes, new AccountTransformer());
|
$collection = new Fractal\Resource\Collection($likes, new AccountTransformer());
|
||||||
return $this->fractal->createData($collection)->toArray();
|
return $this->fractal->createData($collection)->toArray();
|
||||||
|
@ -74,8 +80,8 @@ class PublicApiController extends Controller
|
||||||
|
|
||||||
public function status(Request $request, $username, int $postid)
|
public function status(Request $request, $username, int $postid)
|
||||||
{
|
{
|
||||||
$profile = Profile::whereUsername($username)->first();
|
$profile = Profile::whereUsername($username)->whereNull('status')->firstOrFail();
|
||||||
$status = Status::whereProfileId($profile->id)->find($postid);
|
$status = Status::whereProfileId($profile->id)->findOrFail($postid);
|
||||||
$this->scopeCheck($profile, $status);
|
$this->scopeCheck($profile, $status);
|
||||||
$item = new Fractal\Resource\Item($status, new StatusTransformer());
|
$item = new Fractal\Resource\Item($status, new StatusTransformer());
|
||||||
$res = [
|
$res = [
|
||||||
|
@ -100,8 +106,8 @@ class PublicApiController extends Controller
|
||||||
'limit' => 'nullable|integer|min:5|max:50'
|
'limit' => 'nullable|integer|min:5|max:50'
|
||||||
]);
|
]);
|
||||||
$limit = $request->limit ?? 10;
|
$limit = $request->limit ?? 10;
|
||||||
$profile = Profile::whereUsername($username)->first();
|
$profile = Profile::whereUsername($username)->whereNull('status')->firstOrFail();
|
||||||
$status = Status::whereProfileId($profile->id)->find($postId);
|
$status = Status::whereProfileId($profile->id)->findOrFail($postId);
|
||||||
$this->scopeCheck($profile, $status);
|
$this->scopeCheck($profile, $status);
|
||||||
if($request->filled('min_id') || $request->filled('max_id')) {
|
if($request->filled('min_id') || $request->filled('max_id')) {
|
||||||
if($request->filled('min_id')) {
|
if($request->filled('min_id')) {
|
||||||
|
@ -133,8 +139,8 @@ class PublicApiController extends Controller
|
||||||
|
|
||||||
public function statusLikes(Request $request, $username, $id)
|
public function statusLikes(Request $request, $username, $id)
|
||||||
{
|
{
|
||||||
$profile = Profile::whereUsername($username)->first();
|
$profile = Profile::whereUsername($username)->whereNull('status')->firstOrFail();
|
||||||
$status = Status::whereProfileId($profile->id)->find($id);
|
$status = Status::whereProfileId($profile->id)->findOrFail($id);
|
||||||
$this->scopeCheck($profile, $status);
|
$this->scopeCheck($profile, $status);
|
||||||
$likes = $this->getLikes($status);
|
$likes = $this->getLikes($status);
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
@ -144,8 +150,8 @@ class PublicApiController extends Controller
|
||||||
|
|
||||||
public function statusShares(Request $request, $username, $id)
|
public function statusShares(Request $request, $username, $id)
|
||||||
{
|
{
|
||||||
$profile = Profile::whereUsername($username)->first();
|
$profile = Profile::whereUsername($username)->whereNull('status')->firstOrFail();
|
||||||
$status = Status::whereProfileId($profile->id)->find($id);
|
$status = Status::whereProfileId($profile->id)->findOrFail($id);
|
||||||
$this->scopeCheck($profile, $status);
|
$this->scopeCheck($profile, $status);
|
||||||
$shares = $this->getShares($status);
|
$shares = $this->getShares($status);
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
@ -210,7 +216,7 @@ class PublicApiController extends Controller
|
||||||
// $timeline = Timeline::build()->local();
|
// $timeline = Timeline::build()->local();
|
||||||
$pid = Auth::user()->profile->id;
|
$pid = Auth::user()->profile->id;
|
||||||
|
|
||||||
$private = Profile::whereIsPrivate(true)->where('id', '!=', $pid)->pluck('id');
|
$private = Profile::whereIsPrivate(true)->orWhereNotNull('status')->where('id', '!=', $pid)->pluck('id');
|
||||||
$filters = UserFilter::whereUserId($pid)
|
$filters = UserFilter::whereUserId($pid)
|
||||||
->whereFilterableType('App\Profile')
|
->whereFilterableType('App\Profile')
|
||||||
->whereIn('filter_type', ['mute', 'block'])
|
->whereIn('filter_type', ['mute', 'block'])
|
||||||
|
@ -272,7 +278,7 @@ class PublicApiController extends Controller
|
||||||
$following = Follower::whereProfileId($pid)->pluck('following_id');
|
$following = Follower::whereProfileId($pid)->pluck('following_id');
|
||||||
$following->push($pid)->toArray();
|
$following->push($pid)->toArray();
|
||||||
|
|
||||||
$private = Profile::whereIsPrivate(true)->where('id', '!=', $pid)->pluck('id');
|
$private = Profile::whereIsPrivate(true)->orWhereNotNull('status')->where('id', '!=', $pid)->pluck('id');
|
||||||
$filters = UserFilter::whereUserId($pid)
|
$filters = UserFilter::whereUserId($pid)
|
||||||
->whereFilterableType('App\Profile')
|
->whereFilterableType('App\Profile')
|
||||||
->whereIn('filter_type', ['mute', 'block'])
|
->whereIn('filter_type', ['mute', 'block'])
|
||||||
|
|
Loading…
Reference in a new issue