|
27 | 27 | use Illuminate\Auth\AuthenticationException; |
28 | 28 | use Illuminate\Database\QueryException; |
29 | 29 | use Illuminate\Http\Request; |
| 30 | +use Illuminate\Support\Facades\Log; |
30 | 31 | use Notification; |
31 | 32 | use Illuminate\Validation\ValidationException; |
32 | 33 |
|
@@ -867,12 +868,29 @@ public function createGroupv2(Request $request): JsonResponse { |
867 | 868 | $file->upload('image', 'image', $idGroup, env('TBL_GROUPS'), false, true, true); |
868 | 869 | } |
869 | 870 |
|
870 | | - // Notify relevant admins. |
871 | | - $notify_admins = Fixometer::usersWhoHavePreference('admin-moderate-group'); |
872 | | - Notification::send($notify_admins, new AdminModerationGroup([ |
873 | | - 'group_name' => $name, |
874 | | - 'group_url' => url('/group/edit/'.$idGroup), |
875 | | - ])); |
| 871 | + // Check if groups should be auto-approved |
| 872 | + if (env('FEATURE__AUTO_APPROVE_GROUPS', false) && $user->role <= ROLE::RESTARTER) { |
| 873 | + // Auto-approve the group |
| 874 | + $group->update(['approved' => true]); |
| 875 | + |
| 876 | + // Fire the approval event |
| 877 | + event(new \App\Events\ApproveGroup($group, $data)); |
| 878 | + |
| 879 | + // Notify the creator that their group was approved |
| 880 | + Notification::send($user, new \App\Notifications\GroupConfirmed([ |
| 881 | + 'group_name' => $name, |
| 882 | + 'group_url' => url('/group/view/'.$idGroup), |
| 883 | + ])); |
| 884 | + |
| 885 | + Log::info("Auto-approved group: $idGroup for user {$user->id} (role {$user->role})"); |
| 886 | + } else { |
| 887 | + // Notify relevant admins for moderation. |
| 888 | + $notify_admins = Fixometer::usersWhoHavePreference('admin-moderate-group'); |
| 889 | + Notification::send($notify_admins, new AdminModerationGroup([ |
| 890 | + 'group_name' => $name, |
| 891 | + 'group_url' => url('/group/edit/'.$idGroup), |
| 892 | + ])); |
| 893 | + } |
876 | 894 |
|
877 | 895 | return response()->json([ |
878 | 896 | 'id' => $idGroup, |
|
0 commit comments