forked from mirror/pixelfed
Update ApiV1Dot1Controller
This commit is contained in:
parent
3218719e4c
commit
842f40a1b5
1 changed files with 38 additions and 0 deletions
|
@ -12,6 +12,8 @@ use App\Status;
|
||||||
use App\Report;
|
use App\Report;
|
||||||
use App\Profile;
|
use App\Profile;
|
||||||
use App\Services\AccountService;
|
use App\Services\AccountService;
|
||||||
|
use App\Services\StatusService;
|
||||||
|
use App\Services\ProfileStatusService;
|
||||||
|
|
||||||
class ApiV1Dot1Controller extends Controller
|
class ApiV1Dot1Controller extends Controller
|
||||||
{
|
{
|
||||||
|
@ -166,4 +168,40 @@ class ApiV1Dot1Controller extends Controller
|
||||||
|
|
||||||
return AccountService::get($user->profile_id);
|
return AccountService::get($user->profile_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /api/v1.1/accounts/{id}/posts
|
||||||
|
*
|
||||||
|
* @return \App\Transformer\Api\StatusTransformer
|
||||||
|
*/
|
||||||
|
public function accountPosts(Request $request, $id)
|
||||||
|
{
|
||||||
|
$user = $request->user();
|
||||||
|
|
||||||
|
abort_if(!$user, 403);
|
||||||
|
abort_if($user->status != null, 403);
|
||||||
|
|
||||||
|
$account = AccountService::get($id);
|
||||||
|
|
||||||
|
if(!$account || $account['username'] !== $request->input('username')) {
|
||||||
|
return $this->json([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$posts = ProfileStatusService::get($id);
|
||||||
|
|
||||||
|
if(!$posts) {
|
||||||
|
return $this->json([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = collect($posts)
|
||||||
|
->map(function($id) {
|
||||||
|
return StatusService::get($id);
|
||||||
|
})
|
||||||
|
->filter(function($post) {
|
||||||
|
return $post && isset($post['account']);
|
||||||
|
})
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
return $this->json($res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue