Update ApiV1Dot1Controller

pull/3661/head
Daniel Supernault 2022-09-19 03:49:45 -06:00
rodzic 3218719e4c
commit 842f40a1b5
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 0DEF1C662C9033F7
1 zmienionych plików z 38 dodań i 0 usunięć

Wyświetl plik

@ -12,6 +12,8 @@ use App\Status;
use App\Report;
use App\Profile;
use App\Services\AccountService;
use App\Services\StatusService;
use App\Services\ProfileStatusService;
class ApiV1Dot1Controller extends Controller
{
@ -166,4 +168,40 @@ class ApiV1Dot1Controller extends Controller
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);
}
}