Refactor how repositories for the daemon work.
This commit is contained in:
parent
5f9fe4a69b
commit
d2afc29a80
58 changed files with 388 additions and 997 deletions
|
@ -46,22 +46,20 @@ class RevokeMultipleDaemonKeysService
|
|||
*
|
||||
* @param \Pterodactyl\Models\User $user
|
||||
* @param bool $ignoreConnectionErrors
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function handle(User $user, bool $ignoreConnectionErrors = false)
|
||||
{
|
||||
$keys = $this->repository->getKeysForRevocation($user);
|
||||
|
||||
$keys->groupBy('server.node_id')->each(function ($group, $node) use ($ignoreConnectionErrors) {
|
||||
$keys->groupBy('node.id')->each(function ($group, $nodeId) use ($ignoreConnectionErrors) {
|
||||
try {
|
||||
$this->daemonRepository->setNode($node)->revokeAccessKey(collect($group)->pluck('secret')->toArray());
|
||||
$this->daemonRepository->setNode(collect($group)->first()->getRelation('node'))->revokeAccessKey(collect($group)->pluck('secret')->toArray());
|
||||
} catch (RequestException $exception) {
|
||||
if (! $ignoreConnectionErrors) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
}
|
||||
|
||||
$this->setConnectionException($node, $exception);
|
||||
$this->setConnectionException($nodeId, $exception);
|
||||
}
|
||||
|
||||
$this->repository->deleteKeys(collect($group)->pluck('id')->toArray());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue