mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-26 08:13:16 +00:00
Update ProfileController, cache actor object and atom feed
This commit is contained in:
parent
55003148d4
commit
8665eab190
1 changed files with 42 additions and 29 deletions
|
@ -187,10 +187,12 @@ class ProfileController extends Controller
|
|||
abort_if(!config_cache('federation.activitypub.enabled'), 404);
|
||||
abort_if($user->domain, 404);
|
||||
|
||||
return Cache::remember('pf:activitypub:user-object:by-id:' . $user->id, 3600, function() use($user) {
|
||||
$fractal = new Fractal\Manager();
|
||||
$resource = new Fractal\Resource\Item($user, new ProfileTransformer);
|
||||
$res = $fractal->createData($resource)->toArray();
|
||||
return response(json_encode($res['data']))->header('Content-Type', 'application/activity+json');
|
||||
});
|
||||
}
|
||||
|
||||
public function showAtomFeed(Request $request, $user)
|
||||
|
@ -201,10 +203,11 @@ class ProfileController extends Controller
|
|||
|
||||
abort_if(!$pid, 404);
|
||||
|
||||
$profile = AccountService::get($pid);
|
||||
$profile = AccountService::get($pid, true);
|
||||
|
||||
abort_if(!$profile || $profile['locked'] || !$profile['local'], 404);
|
||||
|
||||
$data = Cache::remember('pf:atom:user-feed:by-id:' . $profile['id'], 86400, function() use($pid, $profile) {
|
||||
$items = DB::table('statuses')
|
||||
->whereProfileId($pid)
|
||||
->whereVisibility('public')
|
||||
|
@ -228,9 +231,19 @@ class ProfileController extends Controller
|
|||
if($items && $items->count()) {
|
||||
$headers['Last-Modified'] = now()->parse($items->first()['created_at'])->toRfc7231String();
|
||||
}
|
||||
|
||||
return compact('items', 'permalink', 'headers');
|
||||
});
|
||||
abort_if(!$data, 404);
|
||||
return response()
|
||||
->view('atom.user', compact('profile', 'items', 'permalink'))
|
||||
->withHeaders($headers);
|
||||
->view('atom.user',
|
||||
[
|
||||
'profile' => $profile,
|
||||
'items' => $data['items'],
|
||||
'permalink' => $data['permalink']
|
||||
]
|
||||
)
|
||||
->withHeaders($data['headers']);
|
||||
}
|
||||
|
||||
public function meRedirect()
|
||||
|
|
Loading…
Reference in a new issue