1
0

credential_account_serializer.rb 690 B

123456789101112131415161718192021222324252627
  1. # frozen_string_literal: true
  2. class REST::CredentialAccountSerializer < REST::AccountSerializer
  3. attributes :source
  4. has_one :role, serializer: REST::RoleSerializer
  5. def source
  6. user = object.user
  7. {
  8. privacy: user.setting_default_privacy,
  9. sensitive: user.setting_default_sensitive,
  10. language: user.setting_default_language,
  11. note: object.note,
  12. fields: object.fields.map(&:to_h),
  13. follow_requests_count: FollowRequest.where(target_account: object).limit(40).count,
  14. hide_collections: object.hide_collections,
  15. discoverable: object.discoverable,
  16. indexable: object.indexable,
  17. }
  18. end
  19. def role
  20. object.user_role
  21. end
  22. end