|
|
|
@ -527,7 +527,7 @@ class ApiV1Controller extends Controller
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($paginator->hasMorePages()) {
|
|
|
|
|
$link .= ($link ? ',' : '') . '<'.$paginator->nextPageUrl().'>; rel="prev"';
|
|
|
|
|
$link .= ($link ? ', ' : '') . '<'.$paginator->nextPageUrl().'>; rel="prev"';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -617,7 +617,7 @@ class ApiV1Controller extends Controller
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($paginator->hasMorePages()) {
|
|
|
|
|
$link .= ($link ? ',' : '') . '<'.$paginator->nextPageUrl().'>; rel="prev"';
|
|
|
|
|
$link .= ($link ? ', ' : '') . '<'.$paginator->nextPageUrl().'>; rel="prev"';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2582,13 +2582,17 @@ class ApiV1Controller extends Controller
|
|
|
|
|
abort_if(!$request->user(), 403);
|
|
|
|
|
|
|
|
|
|
$this->validate($request, [
|
|
|
|
|
'limit' => 'nullable|integer|min:1|max:100'
|
|
|
|
|
'limit' => 'sometimes|integer|min:1|max:80'
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$limit = $request->input('limit') ?? 10;
|
|
|
|
|
$limit = $request->input('limit', 10);
|
|
|
|
|
$user = $request->user();
|
|
|
|
|
$pid = $user->profile_id;
|
|
|
|
|
$status = Status::findOrFail($id);
|
|
|
|
|
$author = intval($status->profile_id) === intval($user->profile_id) || $user->is_admin;
|
|
|
|
|
$account = AccountService::get($status->profile_id, true);
|
|
|
|
|
abort_if(!$account, 404);
|
|
|
|
|
$author = intval($status->profile_id) === intval($pid) || $user->is_admin;
|
|
|
|
|
$napi = $request->has(self::PF_API_ENTITY_KEY);
|
|
|
|
|
|
|
|
|
|
abort_if(
|
|
|
|
|
!$status->type ||
|
|
|
|
@ -2598,10 +2602,14 @@ class ApiV1Controller extends Controller
|
|
|
|
|
|
|
|
|
|
if(!$author) {
|
|
|
|
|
if($status->scope == 'private') {
|
|
|
|
|
abort_if(!FollowerService::follows($user->profile_id, $status->profile_id), 403);
|
|
|
|
|
abort_if(!FollowerService::follows($pid, $status->profile_id), 403);
|
|
|
|
|
} else {
|
|
|
|
|
abort_if(!in_array($status->scope, ['public','unlisted']), 403);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($request->has('cursor')) {
|
|
|
|
|
return $this->json([]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$res = Status::where('reblog_of_id', $status->id)
|
|
|
|
@ -2616,26 +2624,34 @@ class ApiV1Controller extends Controller
|
|
|
|
|
$headers = [];
|
|
|
|
|
if($author && $res->hasPages()) {
|
|
|
|
|
$links = '';
|
|
|
|
|
if($res->previousPageUrl()) {
|
|
|
|
|
$links = '<' . $res->previousPageUrl() .'>; rel="prev"';
|
|
|
|
|
}
|
|
|
|
|
if($res->onFirstPage()) {
|
|
|
|
|
if($res->nextPageUrl()) {
|
|
|
|
|
$links = '<' . $res->nextPageUrl() .'>; rel="prev"';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if($res->previousPageUrl()) {
|
|
|
|
|
$links = '<' . $res->previousPageUrl() .'>; rel="next"';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($res->nextPageUrl()) {
|
|
|
|
|
if(!empty($links)) {
|
|
|
|
|
$links .= ', ';
|
|
|
|
|
if($res->nextPageUrl()) {
|
|
|
|
|
if(!empty($links)) {
|
|
|
|
|
$links .= ', ';
|
|
|
|
|
}
|
|
|
|
|
$links .= '<' . $res->nextPageUrl() .'>; rel="prev"';
|
|
|
|
|
}
|
|
|
|
|
$links .= '<' . $res->nextPageUrl() .'>; rel="next"';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$headers = ['Link' => $links];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$res = $res->map(function($status) use($user) {
|
|
|
|
|
$account = AccountService::getMastodon($status->profile_id, true);
|
|
|
|
|
$res = $res->map(function($status) use($pid, $napi) {
|
|
|
|
|
$account = $napi ? AccountService::get($status->profile_id, true) : AccountService::getMastodon($status->profile_id, true);
|
|
|
|
|
if(!$account) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$account['follows'] = $status->profile_id == $user->profile_id ? null : FollowerService::follows($user->profile_id, $status->profile_id);
|
|
|
|
|
if($napi) {
|
|
|
|
|
$account['follows'] = $status->profile_id == $pid ? null : FollowerService::follows($pid, $status->profile_id);
|
|
|
|
|
}
|
|
|
|
|
return $account;
|
|
|
|
|
})
|
|
|
|
|
->filter(function($account) {
|
|
|
|
|