feat: machine mode, ECH subscriptions, batch ops & security hardening

This commit is contained in:
xboard
2026-04-17 02:27:47 +08:00
parent edbd8de356
commit e297b5fe9f
25 changed files with 1564 additions and 343 deletions
+10 -3
View File
@@ -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);
}
}