From 402ee2cdea044cbd89aa5973b74c898812e16d06 Mon Sep 17 00:00:00 2001 From: Jaton David Date: Thu, 12 Dec 2024 10:45:33 +0100 Subject: [PATCH] Send message in a group if blocked by one member --- app/Http/Controllers/ChatController.php | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/app/Http/Controllers/ChatController.php b/app/Http/Controllers/ChatController.php index 813ff52..74dab29 100644 --- a/app/Http/Controllers/ChatController.php +++ b/app/Http/Controllers/ChatController.php @@ -80,25 +80,7 @@ public function storeMessage(Request $request, $chatId) return response()->json(['error' => 'Chat not found or unauthorized.'], 404); } - if ($chat->members->count() > 2) { - $blockedByAnyone = $chat->members->filter(function ($member) { - return $member->id !== auth()->id(); - })->contains(function ($member) { - $friendship = Friendship::where(function ($query) use ($member) { - $query->where('user_id', auth()->id()) - ->where('friend_id', $member->id); - })->orWhere(function ($query) use ($member) { - $query->where('user_id', $member->id) - ->where('friend_id', auth()->id()); - })->first(); - - return $friendship && $friendship->isBlocked(); - }); - - if ($blockedByAnyone) { - return response()->json(['error' => 'You are blocked by one of the members of this group.']); - } - } else { + if ($chat->members->count() == 2) { $otherMember = $chat->members->firstWhere('id', '!=', auth()->id()); $friendship = Friendship::where(function ($query) use ($otherMember) {