diff --git a/app/Http/Controllers/FollowerController.php b/app/Http/Controllers/FollowerController.php index da4c96dc9..fae861b88 100644 --- a/app/Http/Controllers/FollowerController.php +++ b/app/Http/Controllers/FollowerController.php @@ -2,12 +2,15 @@ namespace App\Http\Controllers; -use App\Follower; -use App\FollowRequest; -use App\Jobs\FollowPipeline\FollowPipeline; -use App\Profile; +use App\{ + Follower, + FollowRequest, + Profile, + UserFilter +}; use Auth; use Illuminate\Http\Request; +use App\Jobs\FollowPipeline\FollowPipeline; class FollowerController extends Controller { @@ -31,6 +34,16 @@ class FollowerController extends Controller $user = Auth::user()->profile; $target = Profile::where('id', '!=', $user->id)->findOrFail($item); $private = (bool) $target->is_private; + $blocked = UserFilter::whereUserId($target->id) + ->whereFilterType('block') + ->whereFilterableId($user->id) + ->whereFilterableType('App\Profile') + ->exists(); + + if($blocked == true) { + return redirect()->back()->with('error', 'You cannot follow this user.'); + } + $isFollowing = Follower::whereProfileId($user->id)->whereFollowingId($target->id)->count(); if($private == true && $isFollowing == 0) { diff --git a/resources/views/profile/private.blade.php b/resources/views/profile/private.blade.php index 8b04a4b40..891f535af 100644 --- a/resources/views/profile/private.blade.php +++ b/resources/views/profile/private.blade.php @@ -1,7 +1,11 @@ @extends('layouts.app',['title' => $user->username . " on " . config('app.name')]) @section('content') - +@if (session('error')) +