Avatar.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 Avatar extends ViolationAbstract
  7. {
  8. /**
  9. * 处理违规头像
  10. */
  11. public function handle()
  12. {
  13. $this->user = UserModel::findOrFail($this->media->uid);
  14. if ($this->user->headimgurl == $this->media->origin) {
  15. switch ($this->media->result) {
  16. case MediaSecure::MANUAL_SUGGESTION_BLOCK:
  17. $this->handleFailed();
  18. break;
  19. case MediaSecure::MANUAL_SUGGESTION_PASS:
  20. $this->handleSuccess();
  21. break;
  22. }
  23. }
  24. }
  25. public function handleFailed()
  26. {
  27. $this->user->headimgurl = '';
  28. $this->user->save();
  29. $this->notification();
  30. }
  31. /**
  32. * 通知
  33. */
  34. public function notification()
  35. {
  36. $payload = [
  37. 'to_user' => $this->user->getAuth(),
  38. 'user' => $this->user->toArray(),
  39. 'meta' => [
  40. 'field' => '头像',
  41. 'handle' => '已更改为默认头像',
  42. ],
  43. ];
  44. dispatch(new RegistEventJob(100015, $payload))->onQueue("{push}");
  45. }
  46. public function handleSuccess()
  47. {
  48. }
  49. }