CreateQuestion.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Transformer\ActivityPub\Verb;
  3. use App\Status;
  4. use League\Fractal;
  5. use Illuminate\Support\Str;
  6. class CreateQuestion extends Fractal\TransformerAbstract
  7. {
  8. protected $defaultIncludes = [
  9. 'object',
  10. ];
  11. public function transform(Status $status)
  12. {
  13. return [
  14. '@context' => [
  15. 'https://www.w3.org/ns/activitystreams',
  16. 'https://w3id.org/security/v1',
  17. [
  18. 'sc' => 'http://schema.org#',
  19. 'Hashtag' => 'as:Hashtag',
  20. 'sensitive' => 'as:sensitive',
  21. 'commentsEnabled' => 'sc:Boolean',
  22. 'capabilities' => [
  23. 'announce' => ['@type' => '@id'],
  24. 'like' => ['@type' => '@id'],
  25. 'reply' => ['@type' => '@id']
  26. ]
  27. ]
  28. ],
  29. 'id' => $status->permalink(),
  30. 'type' => 'Create',
  31. 'actor' => $status->profile->permalink(),
  32. 'published' => $status->created_at->toAtomString(),
  33. 'to' => $status->scopeToAudience('to'),
  34. 'cc' => $status->scopeToAudience('cc'),
  35. ];
  36. }
  37. public function includeObject(Status $status)
  38. {
  39. return $this->item($status, new Question());
  40. }
  41. }