preferences_serializer.rb 1006 B

1234567891011121314151617181920212223242526272829303132333435
  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. attribute :reading_autoplay_gifs, key: 'reading:autoplay:gifs'
  9. def posting_default_privacy
  10. object.user.setting_default_privacy
  11. end
  12. def posting_default_sensitive
  13. object.user.setting_default_sensitive
  14. end
  15. def posting_default_language
  16. object.user.preferred_posting_language
  17. end
  18. def reading_default_sensitive_media
  19. object.user.setting_display_media
  20. end
  21. def reading_default_sensitive_text
  22. object.user.setting_expand_spoilers
  23. end
  24. def reading_autoplay_gifs
  25. object.user.setting_auto_play_gif
  26. end
  27. end