DeleteRemoteStatusPipeline.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace App\Jobs\DeletePipeline;
  3. use Illuminate\Bus\Queueable;
  4. use Illuminate\Contracts\Queue\ShouldBeUnique;
  5. use Illuminate\Contracts\Queue\ShouldQueue;
  6. use Illuminate\Foundation\Bus\Dispatchable;
  7. use Illuminate\Queue\InteractsWithQueue;
  8. use Illuminate\Queue\SerializesModels;
  9. use App\Bookmark;
  10. use App\DirectMessage;
  11. use App\Like;
  12. use App\Media;
  13. use App\MediaTag;
  14. use App\Mention;
  15. use App\Report;
  16. use App\Status;
  17. use App\StatusHashtag;
  18. use App\StatusView;
  19. use App\Notification;
  20. use App\Services\AccountService;
  21. use App\Services\NetworkTimelineService;
  22. use App\Services\StatusService;
  23. use App\Jobs\ProfilePipeline\DecrementPostCount;
  24. use App\Jobs\MediaPipeline\MediaDeletePipeline;
  25. use Cache;
  26. class DeleteRemoteStatusPipeline implements ShouldQueue
  27. {
  28. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  29. protected $status;
  30. public $timeout = 30;
  31. public $tries = 2;
  32. public $maxExceptions = 1;
  33. public $deleteWhenMissingModels = true;
  34. /**
  35. * Create a new job instance.
  36. *
  37. * @return void
  38. */
  39. public function __construct(Status $status)
  40. {
  41. $this->status = $status;
  42. }
  43. /**
  44. * Execute the job.
  45. *
  46. * @return void
  47. */
  48. public function handle()
  49. {
  50. $status = $this->status;
  51. if(AccountService::get($status->profile_id, true)) {
  52. DecrementPostCount::dispatch($status->profile_id)->onQueue('feed');
  53. }
  54. NetworkTimelineService::del($status->id);
  55. StatusService::del($status->id, true);
  56. Bookmark::whereStatusId($status->id)->delete();
  57. Notification::whereItemType('App\Status')
  58. ->whereItemId($status->id)
  59. ->forceDelete();
  60. DirectMessage::whereStatusId($status->id)->delete();
  61. Like::whereStatusId($status->id)->forceDelete();
  62. MediaTag::whereStatusId($status->id)->delete();
  63. Media::whereStatusId($status->id)
  64. ->get()
  65. ->each(function($media) {
  66. MediaDeletePipeline::dispatch($media)->onQueue('mmo');
  67. });
  68. Mention::whereStatusId($status->id)->forceDelete();
  69. Report::whereObjectType('App\Status')->whereObjectId($status->id)->delete();
  70. StatusHashtag::whereStatusId($status->id)->delete();
  71. StatusView::whereStatusId($status->id)->delete();
  72. Status::whereReblogOfId($status->id)->forceDelete();
  73. $status->forceDelete();
  74. return 1;
  75. }
  76. }