Nickname.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace App\Services\Violation;
  3. use App\Models\Media\MediaSecure;
  4. use App\Models\User\UserModel;
  5. use PocketBE\MsyPush\Jobs\RegistEventJob;
  6. class Nickname extends ViolationAbstract
  7. {
  8. public function handle()
  9. {
  10. $this->user = UserModel::findOrFail($this->media->uid);
  11. if ($this->user->nickname == $this->media->origin) {
  12. switch ($this->media->result) {
  13. case MediaSecure::MANUAL_SUGGESTION_BLOCK:
  14. $this->handleFailed();
  15. break;
  16. case MediaSecure::MANUAL_SUGGESTION_PASS:
  17. $this->handleSuccess();
  18. break;
  19. }
  20. }
  21. }
  22. public function handleFailed()
  23. {
  24. $this->user->nickname = '';
  25. $this->user->save();
  26. $this->notification();
  27. }
  28. /**
  29. * 通知
  30. */
  31. public function notification()
  32. {
  33. $payload = [
  34. 'to_user' => $this->user->getAuth(),
  35. 'user' => $this->user->toArray(),
  36. 'meta' => [
  37. 'field' => '昵称',
  38. 'handle' => '已更改为默认昵称',
  39. ],
  40. ];
  41. dispatch(new RegistEventJob(100015, $payload))->onQueue("{push}");
  42. }
  43. public function handleSuccess()
  44. {
  45. }
  46. }