parent
5eae52393d
commit
2547ea25b4
@ -33,7 +33,13 @@ final class Acceptance {
|
||||
$j['id']=$u->id;$j['state']='active';if($apply)writeJson($path,$j);
|
||||
return ['state'=>'ready','id'=>$u->id,'owned'=>$j['owned']];
|
||||
}
|
||||
$u=User::where('group_id',$group)->where('banned',0)->whereRaw('u+d<transfer_enable')->where(fn($q)=>$q->whereNull('expired_at')->orWhere('expired_at','>=',time()))->where('email','not like','node-qa-%')->where('email','not like','batch-acceptance-%')->orderBy('id')->first();
|
||||
$u=null;
|
||||
$candidates=User::where('group_id',$group)->where('banned',0)->whereRaw('u+d<transfer_enable')->where(fn($q)=>$q->whereNull('expired_at')->orWhere('expired_at','>=',time()))->where('email','not like','node-qa-%')->where('email','not like','batch-acceptance-%')->orderByDesc('is_admin')->orderBy('id')->limit(20)->get();
|
||||
foreach($candidates as $candidate){
|
||||
$effective=true;
|
||||
foreach(ServerService::getAvailableServers($candidate) as $s)if(!ServerService::getAvailableUsers(Server::findOrFail($s['id']))->contains('id',$candidate->id)){$effective=false;break;}
|
||||
if($effective){$u=$candidate;break;}
|
||||
}
|
||||
if(!$apply)return ['state'=>$u?'existing':'would_create'];
|
||||
$j=['group'=>$group,'state'=>'prepared','owned'=>!$u,'email'=>$u?->email??'batch-acceptance-'.substr(hash('sha256',$dir),0,12).'-'.Str::lower(Str::random(8)).'@example.invalid','uuid'=>$u?->uuid??(string)Str::uuid(),'token'=>$u?->token??Str::random(32),'quota'=>104857600,'expires_at'=>time()+3600];
|
||||
// Persist identity before commit. A lost response resumes the same row, never another user.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user