You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.2 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. module Mastodon
  2. module Entities
  3. class Account < Grape::Entity
  4. include ApplicationHelper
  5. expose :id
  6. expose :username
  7. expose :domain do |account|
  8. account.local? ? LOCAL_DOMAIN : account.domain
  9. end
  10. expose :display_name
  11. expose :note
  12. expose :url do |account|
  13. account.local? ? profile_url(name: account.username) : account.url
  14. end
  15. end
  16. class Status < Grape::Entity
  17. include ApplicationHelper
  18. format_with(:iso_timestamp) { |dt| dt.iso8601 }
  19. expose :id
  20. expose :uri do |status|
  21. status.local? ? unique_tag(status.stream_entry.created_at, status.stream_entry.activity_id, status.stream_entry.activity_type) : status.uri
  22. end
  23. expose :url do |status|
  24. status.local? ? status_url(name: status.account.username, id: status.id) : status.url
  25. end
  26. expose :text
  27. expose :in_reply_to_id
  28. expose :reblog_of_id
  29. expose :reblog, using: Mastodon::Entities::Status
  30. expose :account, using: Mastodon::Entities::Account
  31. with_options(format_with: :iso_timestamp) do
  32. expose :created_at
  33. expose :updated_at
  34. end
  35. end
  36. end
  37. end