CreateQuestion.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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://w3id.org/security/v1',
  16. 'https://www.w3.org/ns/activitystreams',
  17. [
  18. 'Hashtag' => 'as:Hashtag',
  19. 'sensitive' => 'as:sensitive',
  20. 'schema' => 'http://schema.org/',
  21. 'pixelfed' => 'http://pixelfed.org/ns#',
  22. 'commentsEnabled' => [
  23. '@id' => 'pixelfed:commentsEnabled',
  24. '@type' => 'schema:Boolean'
  25. ],
  26. 'capabilities' => [
  27. '@id' => 'pixelfed:capabilities',
  28. '@container' => '@set'
  29. ],
  30. 'announce' => [
  31. '@id' => 'pixelfed:canAnnounce',
  32. '@type' => '@id'
  33. ],
  34. 'like' => [
  35. '@id' => 'pixelfed:canLike',
  36. '@type' => '@id'
  37. ],
  38. 'reply' => [
  39. '@id' => 'pixelfed:canReply',
  40. '@type' => '@id'
  41. ],
  42. 'toot' => 'http://joinmastodon.org/ns#',
  43. 'Emoji' => 'toot:Emoji'
  44. ]
  45. ],
  46. 'id' => $status->permalink(),
  47. 'type' => 'Create',
  48. 'actor' => $status->profile->permalink(),
  49. 'published' => $status->created_at->toAtomString(),
  50. 'to' => $status->scopeToAudience('to'),
  51. 'cc' => $status->scopeToAudience('cc'),
  52. ];
  53. }
  54. public function includeObject(Status $status)
  55. {
  56. return $this->item($status, new Question());
  57. }
  58. }