diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-03-15 02:39:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-15 02:39:20 +0100 |
commit | d94e21f933f53010f9a3b182e7fde919d73b09a0 (patch) | |
tree | 14f06b20f1ce402c9ed7a4ea11a0073dd0a1106a /app/serializers | |
parent | 85c3bbb23888250bd9caca5d3e8526e8dbdedccc (diff) |
Add a preferences API so apps can share basic behaviours (#10109)
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/rest/preferences_serializer.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/serializers/rest/preferences_serializer.rb b/app/serializers/rest/preferences_serializer.rb new file mode 100644 index 000000000..119f0e06d --- /dev/null +++ b/app/serializers/rest/preferences_serializer.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +class REST::PreferencesSerializer < ActiveModel::Serializer + attribute :posting_default_privacy, key: 'posting:default:visibility' + attribute :posting_default_sensitive, key: 'posting:default:sensitive' + attribute :posting_default_language, key: 'posting:default:language' + + attribute :reading_default_sensitive_media, key: 'reading:expand:media' + attribute :reading_default_sensitive_text, key: 'reading:expand:spoilers' + + def posting_default_privacy + object.user.setting_default_privacy + end + + def posting_default_sensitive + object.user.setting_default_sensitive + end + + def posting_default_language + object.user.setting_default_language.presence + end + + def reading_default_sensitive_media + object.user.setting_display_media + end + + def reading_default_sensitive_text + object.user.setting_expand_spoilers + end +end |