Introduce.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Services\Violation;
  3. use App\Models\Media\MediaSecure;
  4. use App\Models\PartnerModel;
  5. use App\Models\User\UserModel;
  6. use PocketBE\MsyPush\Jobs\RegistEventJob;
  7. class Introduce extends ViolationAbstract
  8. {
  9. public function handle()
  10. {
  11. $this->user = UserModel::findOrFail($this->media->uid);
  12. if ($this->user->introduce == $this->media->origin) {
  13. switch ($this->media->result) {
  14. case MediaSecure::MANUAL_SUGGESTION_BLOCK:
  15. $this->handleFailed();
  16. break;
  17. case MediaSecure::MANUAL_SUGGESTION_PASS:
  18. $this->handleSuccess();
  19. break;
  20. }
  21. }
  22. }
  23. public function handleFailed()
  24. {
  25. $this->user->introduce = '';
  26. $this->user->save();
  27. if ($partner = PartnerModel::find($this->user->partner_id)) {
  28. $partner->introduce = '';
  29. $partner->save();
  30. }
  31. $this->sendFailedNotification();
  32. }
  33. /**
  34. * 通知
  35. */
  36. public function sendFailedNotification()
  37. {
  38. $payload = [
  39. 'to_user' => $this->user->getAuth(),
  40. 'user' => $this->user->toArray(),
  41. 'meta' => [
  42. 'field' => '个性签名',
  43. 'handle' => '已被删除',
  44. ],
  45. ];
  46. dispatch(new RegistEventJob(100015, $payload))->onQueue("{push}");
  47. }
  48. public function handleSuccess()
  49. {
  50. }
  51. }