preferences_serializer.rb 875 B

123456789101112131415161718192021222324252627282930
  1. # frozen_string_literal: true
  2. class REST::PreferencesSerializer < ActiveModel::Serializer
  3. attribute :posting_default_privacy, key: 'posting:default:visibility'
  4. attribute :posting_default_sensitive, key: 'posting:default:sensitive'
  5. attribute :posting_default_language, key: 'posting:default:language'
  6. attribute :reading_default_sensitive_media, key: 'reading:expand:media'
  7. attribute :reading_default_sensitive_text, key: 'reading:expand:spoilers'
  8. def posting_default_privacy
  9. object.user.setting_default_privacy
  10. end
  11. def posting_default_sensitive
  12. object.user.setting_default_sensitive
  13. end
  14. def posting_default_language
  15. object.user.setting_default_language.presence
  16. end
  17. def reading_default_sensitive_media
  18. object.user.setting_display_media
  19. end
  20. def reading_default_sensitive_text
  21. object.user.setting_expand_spoilers
  22. end
  23. end