Merge pull request #3144 from pixelfed/staging

Staging
This commit is contained in:
daniel 2022-01-09 20:21:46 -07:00 committed by GitHub
commit f543073778
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 69 deletions

View file

@ -92,6 +92,7 @@
- Updated components, fix api endpoints. Fixes #3138. ([e724633e](https://github.com/pixelfed/pixelfed/commit/e724633e)) - Updated components, fix api endpoints. Fixes #3138. ([e724633e](https://github.com/pixelfed/pixelfed/commit/e724633e))
- Updated ApiV1Controller, fix public timeline endpoint. ([80c7def3](https://github.com/pixelfed/pixelfed/commit/80c7def3)) - Updated ApiV1Controller, fix public timeline endpoint. ([80c7def3](https://github.com/pixelfed/pixelfed/commit/80c7def3))
- Updated PublicApiController, fix public timeline endpoint. ([dcb7ba9c](https://github.com/pixelfed/pixelfed/commit/dcb7ba9c)) - Updated PublicApiController, fix public timeline endpoint. ([dcb7ba9c](https://github.com/pixelfed/pixelfed/commit/dcb7ba9c))
- Updated ApiV1Controller, fix home timeline entities. ([6fc0dcb3](https://github.com/pixelfed/pixelfed/commit/6fc0dcb3))
- ([](https://github.com/pixelfed/pixelfed/commit/)) - ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.1 (2021-09-07)](https://github.com/pixelfed/pixelfed/compare/v0.11.0...v0.11.1) ## [v0.11.1 (2021-09-07)](https://github.com/pixelfed/pixelfed/compare/v0.11.0...v0.11.1)

View file

@ -1596,8 +1596,6 @@ class ApiV1Controller extends Controller
*/ */
public function timelineHome(Request $request) public function timelineHome(Request $request)
{ {
abort_if(!$request->user(), 403);
$this->validate($request,[ $this->validate($request,[
'page' => 'nullable|integer|max:40', 'page' => 'nullable|integer|max:40',
'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX, 'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
@ -1609,18 +1607,6 @@ class ApiV1Controller extends Controller
$min = $request->input('min_id'); $min = $request->input('min_id');
$max = $request->input('max_id'); $max = $request->input('max_id');
$limit = $request->input('limit') ?? 3; $limit = $request->input('limit') ?? 3;
$user = $request->user();
if($user->last_active_at) {
$key = 'user:last_active_at:id:'.$user->id;
$ttl = now()->addMinutes(5);
Cache::remember($key, $ttl, function() use($user) {
$user->last_active_at = now();
$user->save();
return;
});
}
$pid = $request->user()->profile_id; $pid = $request->user()->profile_id;
$following = Cache::remember('profile:following:'.$pid, now()->addMinutes(1440), function() use($pid) { $following = Cache::remember('profile:following:'.$pid, now()->addMinutes(1440), function() use($pid) {
@ -1631,63 +1617,68 @@ class ApiV1Controller extends Controller
if($min || $max) { if($min || $max) {
$dir = $min ? '>' : '<'; $dir = $min ? '>' : '<';
$id = $min ?? $max; $id = $min ?? $max;
$timeline = Status::select( $res = Status::select(
'id', 'id',
'uri', 'profile_id',
'caption', 'type',
'rendered', 'visibility',
'profile_id', 'created_at'
'type', )
'in_reply_to_id', ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
'reblog_of_id', ->where('id', $dir, $id)
'is_nsfw', ->whereIn('profile_id', $following)
'scope', ->whereIn('visibility',['public', 'unlisted', 'private'])
'local', ->latest()
'reply_count', ->take($limit)
'likes_count', ->get()
'reblogs_count', ->map(function($s) use($pid) {
'comments_disabled', $status = StatusService::getMastodon($s['id']);
'place_id', if(!$status || !isset($status['account']) || !isset($status['account']['id'])) {
'created_at', return false;
'updated_at' }
)->whereIn('type', ['photo', 'photo:album', 'video', 'video:album'])
->with('profile', 'hashtags', 'mentions') if($pid) {
->where('id', $dir, $id) $status['favourited'] = (bool) LikeService::liked($pid, $s['id']);
->whereIn('profile_id', $following) }
->whereIn('visibility',['public', 'unlisted', 'private']) return $status;
->latest() })
->limit($limit) ->filter(function($status) {
->get(); return $status && isset($status['account']);
})
->values()
->toArray();
} else { } else {
$timeline = Status::select( $res = Status::select(
'id', 'id',
'uri', 'profile_id',
'caption', 'type',
'rendered', 'visibility',
'profile_id', 'created_at'
'type', )
'in_reply_to_id', ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
'reblog_of_id', ->whereIn('profile_id', $following)
'is_nsfw', ->whereIn('visibility',['public', 'unlisted', 'private'])
'scope', ->latest()
'local', ->take($limit)
'reply_count', ->get()
'comments_disabled', ->map(function($s) use($pid) {
'likes_count', $status = StatusService::getMastodon($s['id']);
'reblogs_count', if(!$status || !isset($status['account']) || !isset($status['account']['id'])) {
'place_id', return false;
'created_at', }
'updated_at'
)->whereIn('type', ['photo', 'photo:album', 'video', 'video:album']) if($pid) {
->with('profile', 'hashtags', 'mentions') $status['favourited'] = (bool) LikeService::liked($pid, $s['id']);
->whereIn('profile_id', $following) }
->whereIn('visibility',['public', 'unlisted', 'private']) return $status;
->latest() })
->simplePaginate($limit); ->filter(function($status) {
return $status && isset($status['account']);
})
->values()
->toArray();
} }
$fractal = new Fractal\Resource\Collection($timeline, new StatusTransformer());
$res = $this->fractal->createData($fractal)->toArray();
return response()->json($res); return response()->json($res);
} }
@ -1800,7 +1791,6 @@ class ApiV1Controller extends Controller
if($user) { if($user) {
$status['favourited'] = (bool) LikeService::liked($user->profile_id, $k); $status['favourited'] = (bool) LikeService::liked($user->profile_id, $k);
$status['relationship'] = RelationshipService::get($user->profile_id, $status['account']['id']);
} }
return $status; return $status;
}) })