Question.php 1.3 KB

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