AdminNewAutospam.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace App\Mail;
  3. use Illuminate\Bus\Queueable;
  4. use Illuminate\Contracts\Queue\ShouldQueue;
  5. use Illuminate\Mail\Mailable;
  6. use Illuminate\Mail\Mailables\Content;
  7. use Illuminate\Mail\Mailables\Envelope;
  8. use Illuminate\Queue\SerializesModels;
  9. use App\Services\AccountService;
  10. use App\Services\StatusService;
  11. class AdminNewAutospam extends Mailable
  12. {
  13. use Queueable, SerializesModels;
  14. public $report;
  15. /**
  16. * Create a new message instance.
  17. *
  18. * @return void
  19. */
  20. public function __construct($report)
  21. {
  22. $this->report = $report;
  23. }
  24. /**
  25. * Get the message envelope.
  26. *
  27. * @return \Illuminate\Mail\Mailables\Envelope
  28. */
  29. public function envelope()
  30. {
  31. return new Envelope(
  32. subject: '[' . config('pixelfed.domain.app') . '] Spam Post Detected (Ref: autospam-' . $this->report->id . ')',
  33. );
  34. }
  35. /**
  36. * Get the message content definition.
  37. *
  38. * @return \Illuminate\Mail\Mailables\Content
  39. */
  40. public function content()
  41. {
  42. $data = $this->report->toArray();
  43. $reported_status = null;
  44. $reported_account = null;
  45. $url = url('/i/admin/reports/autospam/' . $this->report->id . '?ref=email');
  46. if($data['item_type'] === 'App\Status') {
  47. $reported_status = StatusService::get($this->report->item_id, false);
  48. $reported_account = AccountService::get($reported_status['account']['id'], true);
  49. }
  50. return new Content(
  51. markdown: 'emails.admin.new_autospam',
  52. with: [
  53. 'report' => $data,
  54. 'url' => $url,
  55. 'reported_status' => $reported_status,
  56. 'reported_account' => $reported_account
  57. ]
  58. );
  59. }
  60. /**
  61. * Get the attachments for the message.
  62. *
  63. * @return array
  64. */
  65. public function attachments()
  66. {
  67. return [];
  68. }
  69. }