From 4db7b72747396004aca9fd0bb72174e2b4fac5d4 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 30 Aug 2018 21:43:43 -0600 Subject: [PATCH 01/11] Update UserFilter model --- app/UserFilter.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/UserFilter.php b/app/UserFilter.php index ab5fe321a..50cd5887e 100644 --- a/app/UserFilter.php +++ b/app/UserFilter.php @@ -12,4 +12,21 @@ class UserFilter extends Model 'filterable_type', 'filter_type', ]; + + public function mutedUserIds($profile_id) + { + return $this->whereUserId($profile_id) + ->whereFilterableType('App\Profile') + ->whereFilterType('mute') + ->pluck('filterable_id'); + } + + + public function blockedUserIds($profile_id) + { + return $this->whereUserId($profile_id) + ->whereFilterableType('App\Profile') + ->whereFilterType('block') + ->pluck('filterable_id'); + } } From 2810b952ddd60650b685530bae0cdc9bb48e5158 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 30 Aug 2018 21:47:25 -0600 Subject: [PATCH 02/11] Update SiteController, add mutes and blocks to personal timeline --- app/Http/Controllers/SiteController.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Http/Controllers/SiteController.php b/app/Http/Controllers/SiteController.php index ec4b00d72..de6e0c874 100644 --- a/app/Http/Controllers/SiteController.php +++ b/app/Http/Controllers/SiteController.php @@ -7,6 +7,7 @@ use App\Follower; use App\Profile; use App\Status; use App\User; +use App\UserFilter; use App\Util\Lexer\PrettyNumber; use Auth; use Cache; @@ -30,10 +31,16 @@ class SiteController extends Controller public function homeTimeline() { + $pid = Auth::user()->profile->id; // TODO: Use redis for timelines $following = Follower::whereProfileId(Auth::user()->profile->id)->pluck('following_id'); $following->push(Auth::user()->profile->id); + $filtered = UserFilter::whereUserId($pid) + ->whereFilterableType('App\Profile') + ->whereIn('filter_type', ['mute', 'block']) + ->pluck('filterable_id'); $timeline = Status::whereIn('profile_id', $following) + ->whereNotIn('profile_id', $filtered) ->whereHas('media') ->orderBy('id', 'desc') ->withCount(['comments', 'likes', 'shares']) From 0af5547dbbe74ad89df96d9dfb1295aad52b83e8 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 30 Aug 2018 22:18:43 -0600 Subject: [PATCH 03/11] Update DiscoverController --- app/Http/Controllers/DiscoverController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Http/Controllers/DiscoverController.php b/app/Http/Controllers/DiscoverController.php index 09cd8b1ae..fada324fe 100644 --- a/app/Http/Controllers/DiscoverController.php +++ b/app/Http/Controllers/DiscoverController.php @@ -6,6 +6,7 @@ use App\Follower; use App\Hashtag; use App\Profile; use App\Status; +use App\UserFilter; use Auth; use Illuminate\Http\Request; @@ -23,6 +24,13 @@ class DiscoverController extends Controller $following = Follower::whereProfileId($pid) ->pluck('following_id'); + $filtered = UserFilter::whereUserId($pid) + ->whereFilterableType('App\Profile') + ->whereIn('filter_type', ['mute', 'block']) + ->pluck('filterable_id'); + + $following = $following->push($filtered); + $people = Profile::inRandomOrder() ->where('id', '!=', $pid) ->whereNotIn('id', $following) From b110bc55681b594c9d7cd594f2e6b3afa8c96696 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 30 Aug 2018 22:19:31 -0600 Subject: [PATCH 04/11] Update user settings sidebar --- resources/views/settings/partial/sidebar.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/settings/partial/sidebar.blade.php b/resources/views/settings/partial/sidebar.blade.php index 18588b59a..04fa93991 100644 --- a/resources/views/settings/partial/sidebar.blade.php +++ b/resources/views/settings/partial/sidebar.blade.php @@ -16,7 +16,7 @@ Notifications --}} - {{--