DomainBlockResource.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Http\Resources\MastoApi\Admin;
  3. use Illuminate\Http\Request;
  4. use Illuminate\Http\Resources\Json\JsonResource;
  5. class DomainBlockResource extends JsonResource
  6. {
  7. /**
  8. * Transform the resource into an array.
  9. *
  10. * @return array<string, mixed>
  11. */
  12. public function toArray(Request $request): array
  13. {
  14. $severity = 'noop';
  15. if ($this->banned) {
  16. $severity = 'suspend';
  17. } else if ($this->unlisted) {
  18. $severity = 'silence';
  19. }
  20. return [
  21. 'id' => $this->id,
  22. 'domain' => $this->domain,
  23. // This property is coming in Mastodon 4.3, although it'll only be
  24. // useful if Pixelfed supports obfuscating domains:
  25. 'digest' => hash('sha256', $this->domain),
  26. 'severity' => $severity,
  27. // Using the updated_at value as this is going to be the closest to
  28. // when the domain was banned
  29. 'created_at' => $this->updated_at,
  30. // We don't have data for these fields
  31. 'reject_media' => false,
  32. 'reject_reports' => false,
  33. 'private_comment' => $this->notes ? join('; ', $this->notes) : null,
  34. 'public_comment' => $this->limit_reason,
  35. 'obfuscate' => false
  36. ];
  37. }
  38. }