mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-24 03:57:27 +08:00
feat: machine mode, ECH subscriptions, batch ops & security hardening
This commit is contained in:
@@ -8,6 +8,8 @@ use App\Services\TrafficResetService;
|
||||
|
||||
class UserObserver
|
||||
{
|
||||
public bool $afterCommit = true;
|
||||
|
||||
public function __construct(
|
||||
private readonly TrafficResetService $trafficResetService
|
||||
) {
|
||||
@@ -15,12 +17,17 @@ class UserObserver
|
||||
|
||||
public function updated(User $user): void
|
||||
{
|
||||
if ($user->isDirty(['plan_id', 'expired_at'])) {
|
||||
// With $afterCommit = true, isDirty() is always false after commit.
|
||||
// Use wasChanged() to detect what was actually modified.
|
||||
$syncFields = ['group_id', 'uuid', 'speed_limit', 'device_limit', 'banned', 'expired_at', 'transfer_enable', 'u', 'd', 'plan_id'];
|
||||
$needsSync = $user->wasChanged($syncFields);
|
||||
$oldGroupId = $user->wasChanged('group_id') ? $user->getOriginal('group_id') : null;
|
||||
|
||||
if ($user->wasChanged(['plan_id', 'expired_at'])) {
|
||||
$this->recalculateNextResetAt($user);
|
||||
}
|
||||
|
||||
if ($user->isDirty(['group_id', 'uuid', 'speed_limit', 'device_limit', 'banned', 'expired_at', 'transfer_enable', 'u', 'd', 'plan_id'])) {
|
||||
$oldGroupId = $user->isDirty('group_id') ? $user->getOriginal('group_id') : null;
|
||||
if ($needsSync) {
|
||||
NodeUserSyncJob::dispatch($user->id, 'updated', $oldGroupId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user