diff options
author | Starfall <us@starfall.systems> | 2022-06-06 13:35:20 -0500 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2022-06-06 13:35:20 -0500 |
commit | 78266a002b4735caaef07098ba66419fd71f47c1 (patch) | |
tree | 4ba2bc330d5ed4b6a3a926ab9a03a89f56bc8843 /app/serializers | |
parent | e9b2e11520056d0ec822ac0862923d00c6a1289c (diff) | |
parent | 434b08e95b1a440bf9ae563b72600d1590106260 (diff) |
Merge remote-tracking branch 'glitch/main'
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/initial_state_serializer.rb | 8 | ||||
-rw-r--r-- | app/serializers/rest/account_serializer.rb | 7 | ||||
-rw-r--r-- | app/serializers/rest/preferences_serializer.rb | 2 | ||||
-rw-r--r-- | app/serializers/rss/account_serializer.rb | 28 | ||||
-rw-r--r-- | app/serializers/rss/tag_serializer.rb | 25 |
5 files changed, 14 insertions, 56 deletions
diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index a05164641..5eab02dbc 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -3,7 +3,8 @@ class InitialStateSerializer < ActiveModel::Serializer attributes :meta, :compose, :accounts, :media_attachments, :settings, - :max_toot_chars, :poll_limits + :max_toot_chars, :poll_limits, + :languages has_one :push_subscription, serializer: REST::WebPushSubscriptionSerializer @@ -76,6 +77,7 @@ class InitialStateSerializer < ActiveModel::Serializer store[:me] = object.current_account.id.to_s store[:default_privacy] = object.visibility || object.current_account.user.setting_default_privacy store[:default_sensitive] = object.current_account.user.setting_default_sensitive + store[:default_language] = object.current_account.user.preferred_posting_language end store[:text] = object.text if object.text @@ -94,6 +96,10 @@ class InitialStateSerializer < ActiveModel::Serializer { accept_content_types: MediaAttachment.supported_file_extensions + MediaAttachment.supported_mime_types } end + def languages + LanguagesHelper::SUPPORTED_LOCALES.map { |(key, value)| [key, value[0], value[1]] } + end + private def instance_presenter diff --git a/app/serializers/rest/account_serializer.rb b/app/serializers/rest/account_serializer.rb index 113e0cca7..e644a3f91 100644 --- a/app/serializers/rest/account_serializer.rb +++ b/app/serializers/rest/account_serializer.rb @@ -13,6 +13,7 @@ class REST::AccountSerializer < ActiveModel::Serializer has_many :emojis, serializer: REST::CustomEmojiSerializer attribute :suspended, if: :suspended? + attribute :silenced, key: :limited, if: :silenced? class FieldSerializer < ActiveModel::Serializer include FormattingHelper @@ -102,7 +103,11 @@ class REST::AccountSerializer < ActiveModel::Serializer object.suspended? end - delegate :suspended?, to: :object + def silenced + object.silenced? + end + + delegate :suspended?, :silenced?, to: :object def moved_and_not_nested? object.moved? && object.moved_to_account.moved_to_account_id.nil? diff --git a/app/serializers/rest/preferences_serializer.rb b/app/serializers/rest/preferences_serializer.rb index 119f0e06d..874bd990d 100644 --- a/app/serializers/rest/preferences_serializer.rb +++ b/app/serializers/rest/preferences_serializer.rb @@ -17,7 +17,7 @@ class REST::PreferencesSerializer < ActiveModel::Serializer end def posting_default_language - object.user.setting_default_language.presence + object.user.preferred_posting_language end def reading_default_sensitive_media diff --git a/app/serializers/rss/account_serializer.rb b/app/serializers/rss/account_serializer.rb deleted file mode 100644 index 81e24af0d..000000000 --- a/app/serializers/rss/account_serializer.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -class RSS::AccountSerializer < RSS::Serializer - include ActionView::Helpers::NumberHelper - include AccountsHelper - include RoutingHelper - - def render(account, statuses, tag) - builder = RSSBuilder.new - - builder.title("#{display_name(account)} (@#{account.local_username_and_domain})") - .description(account_description(account)) - .link(tag.present? ? short_account_tag_url(account, tag) : short_account_url(account)) - .logo(full_pack_url('media/images/logo.svg')) - .accent_color('2b90d9') - - builder.image(full_asset_url(account.avatar.url(:original))) if account.avatar? - builder.cover(full_asset_url(account.header.url(:original))) if account.header? - - render_statuses(builder, statuses) - - builder.to_xml - end - - def self.render(account, statuses, tag) - new.render(account, statuses, tag) - end -end diff --git a/app/serializers/rss/tag_serializer.rb b/app/serializers/rss/tag_serializer.rb deleted file mode 100644 index e549ac367..000000000 --- a/app/serializers/rss/tag_serializer.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class RSS::TagSerializer < RSS::Serializer - include ActionView::Helpers::NumberHelper - include ActionView::Helpers::SanitizeHelper - include RoutingHelper - - def render(tag, statuses) - builder = RSSBuilder.new - - builder.title("##{tag.name}") - .description(strip_tags(I18n.t('about.about_hashtag_html', hashtag: tag.name))) - .link(tag_url(tag)) - .logo(full_pack_url('media/images/logo.svg')) - .accent_color('2b90d9') - - render_statuses(builder, statuses) - - builder.to_xml - end - - def self.render(tag, statuses) - new.render(tag, statuses) - end -end |