The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

55 lines
1.2 KiB

  1. # frozen_string_literal: true
  2. class REST::AccountSerializer < ActiveModel::Serializer
  3. include RoutingHelper
  4. attributes :id, :username, :acct, :display_name, :locked, :bot, :created_at,
  5. :note, :url, :avatar, :avatar_static, :header, :header_static,
  6. :followers_count, :following_count, :statuses_count
  7. has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
  8. has_many :emojis, serializer: REST::CustomEmojiSerializer
  9. class FieldSerializer < ActiveModel::Serializer
  10. attributes :name, :value
  11. def value
  12. Formatter.instance.format_field(object.account, object.value)
  13. end
  14. end
  15. has_many :fields
  16. def id
  17. object.id.to_s
  18. end
  19. def note
  20. Formatter.instance.simplified_format(object, custom_emojify: true)
  21. end
  22. def url
  23. TagManager.instance.url_for(object)
  24. end
  25. def avatar
  26. full_asset_url(object.avatar_original_url)
  27. end
  28. def avatar_static
  29. full_asset_url(object.avatar_static_url)
  30. end
  31. def header
  32. full_asset_url(object.header_original_url)
  33. end
  34. def header_static
  35. full_asset_url(object.header_static_url)
  36. end
  37. def moved_and_not_nested?
  38. object.moved? && object.moved_to_account.moved_to_account_id.nil?
  39. end
  40. end