Commit 660d4a19 authored by Mahmoud Aglan's avatar Mahmoud Aglan

Disable auto-suspend by default (opt-in via setting)

Both the scheduled command and the real-time listener now check
'auto_suspend_on_threshold' setting (default: false). Auto-suspend
will only fire if explicitly enabled in system_settings.

This prevents participants from being repeatedly suspended after
reactivation due to old attendance records in the lookback window.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 2717165c
...@@ -20,6 +20,11 @@ class SendAttendanceAlerts extends Command ...@@ -20,6 +20,11 @@ class SendAttendanceAlerts extends Command
public function handle(SettingsService $settings): int public function handle(SettingsService $settings): int
{ {
if (!(bool) $settings->get('auto_suspend_on_threshold', false)) {
$this->info('Auto-suspend is disabled (auto_suspend_on_threshold = false). Skipping.');
return self::SUCCESS;
}
$threshold = (float) ($settings->get('min_attendance_percent', self::DEFAULT_MIN_ATTENDANCE_PERCENT)); $threshold = (float) ($settings->get('min_attendance_percent', self::DEFAULT_MIN_ATTENDANCE_PERCENT));
$participants = Participant::where('status', 'active')->get(); $participants = Participant::where('status', 'active')->get();
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
use App\Domain\Attendance\Events\AttendanceThresholdBreached; use App\Domain\Attendance\Events\AttendanceThresholdBreached;
use App\Domain\Participant\Services\ParticipantService; use App\Domain\Participant\Services\ParticipantService;
use App\Domain\Shared\Services\SettingsService;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
...@@ -11,11 +12,16 @@ class SuspendOnThreshold implements ShouldQueue ...@@ -11,11 +12,16 @@ class SuspendOnThreshold implements ShouldQueue
{ {
public function __construct( public function __construct(
private ParticipantService $participantService, private ParticipantService $participantService,
private SettingsService $settings,
) {} ) {}
public function handle(AttendanceThresholdBreached $event): void public function handle(AttendanceThresholdBreached $event): void
{ {
try { try {
if (!(bool) $this->settings->get('auto_suspend_on_threshold', false)) {
return;
}
$participant = $event->participant; $participant = $event->participant;
if ($participant->status === 'suspended' || $participant->status === 'blacklisted') { if ($participant->status === 'suspended' || $participant->status === 'blacklisted') {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment