Merge pull request #434 from pixelfed/frontend-ui-refactor

Update ProfileController
This commit is contained in:
daniel 2018-09-01 23:48:04 -06:00 committed by GitHub
commit 9c1b714342
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -86,7 +86,7 @@ class ProfileController extends Controller
} }
$user = Auth::user()->profile; $user = Auth::user()->profile;
if($user->id == $profile->id) { if($user->id == $profile->id || !$profile->is_private) {
return false; return false;
} }
@ -124,7 +124,14 @@ class ProfileController extends Controller
public function showAtomFeed(Request $request, $user) public function showAtomFeed(Request $request, $user)
{ {
$profile = Profile::whereUsername($user)->firstOrFail(); $profile = $user = Profile::whereUsername($user)->firstOrFail();
if($profile->is_private || Auth::check()) {
$blocked = $this->blockedProfileCheck($profile);
$check = $this->privateProfileCheck($profile, null);
if($check || $blocked) {
return view('profile.private', compact('user'));
}
}
$items = $profile->statuses()->orderBy('created_at', 'desc')->take(10)->get(); $items = $profile->statuses()->orderBy('created_at', 'desc')->take(10)->get();
return response()->view('atom.user', compact('profile', 'items')) return response()->view('atom.user', compact('profile', 'items'))
->header('Content-Type', 'application/atom+xml'); ->header('Content-Type', 'application/atom+xml');
@ -134,6 +141,13 @@ class ProfileController extends Controller
{ {
$profile = $user = Profile::whereUsername($username)->firstOrFail(); $profile = $user = Profile::whereUsername($username)->firstOrFail();
// TODO: fix $profile/$user mismatch in profile & follower templates // TODO: fix $profile/$user mismatch in profile & follower templates
if($profile->is_private || Auth::check()) {
$blocked = $this->blockedProfileCheck($profile);
$check = $this->privateProfileCheck($profile, null);
if($check || $blocked) {
return view('profile.private', compact('user'));
}
}
$owner = Auth::check() && Auth::id() === $user->user_id; $owner = Auth::check() && Auth::id() === $user->user_id;
$is_following = ($owner == false && Auth::check()) ? $user->followedBy(Auth::user()->profile) : false; $is_following = ($owner == false && Auth::check()) ? $user->followedBy(Auth::user()->profile) : false;
$followers = $profile->followers()->orderBy('created_at', 'desc')->simplePaginate(12); $followers = $profile->followers()->orderBy('created_at', 'desc')->simplePaginate(12);
@ -149,8 +163,15 @@ class ProfileController extends Controller
public function following(Request $request, $username) public function following(Request $request, $username)
{ {
$profile = Profile::whereUsername($username)->firstOrFail(); $profile = $user = Profile::whereUsername($username)->firstOrFail();
// TODO: fix $profile/$user mismatch in profile & follower templates // TODO: fix $profile/$user mismatch in profile & follower templates
if($profile->is_private || Auth::check()) {
$blocked = $this->blockedProfileCheck($profile);
$check = $this->privateProfileCheck($profile, null);
if($check || $blocked) {
return view('profile.private', compact('user'));
}
}
$user = $profile; $user = $profile;
$owner = Auth::check() && Auth::id() === $user->user_id; $owner = Auth::check() && Auth::id() === $user->user_id;
$is_following = ($owner == false && Auth::check()) ? $user->followedBy(Auth::user()->profile) : false; $is_following = ($owner == false && Auth::check()) ? $user->followedBy(Auth::user()->profile) : false;