From 10cfb02a9e988815069c4df13fb85e9a77c942db Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 22 Nov 2018 12:30:20 -0700 Subject: [PATCH] Update AccountController. Fixes #582 --- app/Http/Controllers/AccountController.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 83811026..a06bb9ff 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -203,6 +203,16 @@ class AccountController extends Controller 'filter_type' => 'mute', ]); + $pid = $user->id; + Cache::remember("user:filter:list:$pid", 1440, function() use($pid) { + $private = Profile::whereIsPrivate(true)->where('id', '!=', $pid)->pluck('id'); + $filters = UserFilter::whereUserId($pid) + ->whereFilterableType('App\Profile') + ->whereIn('filter_type', ['mute', 'block']) + ->pluck('filterable_id')->toArray(); + return array_merge($private->toArray(), $filters); + }); + return redirect()->back(); } @@ -224,6 +234,9 @@ class AccountController extends Controller switch ($type) { case 'user': $profile = Profile::findOrFail($item); + if ($profile->id == $user->id) { + return abort(403); + } $class = get_class($profile); $filterable['id'] = $profile->id; $filterable['type'] = $class; @@ -244,6 +257,15 @@ class AccountController extends Controller 'filter_type' => 'block', ]); + $pid = $user->id; + Cache::remember("user:filter:list:$pid", 1440, function() use($pid) { + $private = Profile::whereIsPrivate(true)->where('id', '!=', $pid)->pluck('id'); + $filters = UserFilter::whereUserId($pid) + ->whereFilterableType('App\Profile') + ->whereIn('filter_type', ['mute', 'block']) + ->pluck('filterable_id')->toArray(); + return array_merge($private->toArray(), $filters); + }); return redirect()->back(); }