delUser.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Jobs\VNet;
  3. use Http;
  4. use Illuminate\Bus\Queueable;
  5. use Illuminate\Contracts\Queue\ShouldQueue;
  6. use Illuminate\Foundation\Bus\Dispatchable;
  7. use Illuminate\Queue\InteractsWithQueue;
  8. use Illuminate\Queue\SerializesModels;
  9. class delUser implements ShouldQueue
  10. {
  11. use Dispatchable;
  12. use InteractsWithQueue;
  13. use Queueable;
  14. use SerializesModels;
  15. private $userIds;
  16. private $nodes;
  17. public function __construct($userIds, $nodes)
  18. {
  19. $this->userIds = $userIds;
  20. $this->nodes = $nodes;
  21. }
  22. public function handle(): void
  23. {
  24. foreach ($this->nodes as $node) {
  25. $this->send(($node->server ?: $node->ip).':'.$node->push_port, $node->auth->secret);
  26. }
  27. }
  28. private function send($host, $secret): void
  29. {
  30. $client = Http::baseUrl($host)->timeout(15)->withHeaders(['secret' => $secret]);
  31. if (is_array($this->userIds)) {
  32. $client->post('api/v2/user/del/list', $this->userIds);
  33. } else {
  34. $client->post('api/user/del/'.$this->userIds);
  35. }
  36. }
  37. }