credential_account_serializer.rb 565 B

123456789101112131415161718192021222324
  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. }
  15. end
  16. def role
  17. object.user_role
  18. end
  19. end