From 9b3181923c0734eb38579aeb3398d34afdcd85ca Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 16 Nov 2021 19:08:52 -0500 Subject: [PATCH] Fix social post voter --- .../Security/Authorization/Voter/SocialPostVoter.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/CoreBundle/Security/Authorization/Voter/SocialPostVoter.php b/src/CoreBundle/Security/Authorization/Voter/SocialPostVoter.php index 346456fda1..4f96a3141b 100644 --- a/src/CoreBundle/Security/Authorization/Voter/SocialPostVoter.php +++ b/src/CoreBundle/Security/Authorization/Voter/SocialPostVoter.php @@ -68,11 +68,15 @@ class SocialPostVoter extends Voter /** @var SocialPost $post */ $post = $subject; $sender = $post->getSender(); + $userReceiver = $post->getUserReceiver(); switch ($attribute) { case self::CREATE: - if ($currentUser->hasFriendWithRelationType($sender, UserRelUser::USER_RELATION_TYPE_FRIEND)) { - return true; + if ( + $userReceiver && + !$sender->hasFriendWithRelationType($userReceiver, UserRelUser::USER_RELATION_TYPE_FRIEND) + ) { + return false; } // no break case self::EDIT: @@ -86,6 +90,6 @@ class SocialPostVoter extends Voter return true; } - return true; + return false; } }