diff options
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/activitypub/follow_serializer.rb | 9 | ||||
-rw-r--r-- | app/serializers/initial_state_serializer.rb | 10 | ||||
-rw-r--r-- | app/serializers/manifest_serializer.rb | 7 | ||||
-rw-r--r-- | app/serializers/rest/instance_serializer.rb | 6 | ||||
-rw-r--r-- | app/serializers/rest/mute_serializer.rb | 15 |
5 files changed, 36 insertions, 11 deletions
diff --git a/app/serializers/activitypub/follow_serializer.rb b/app/serializers/activitypub/follow_serializer.rb index eecd64701..86c9992fe 100644 --- a/app/serializers/activitypub/follow_serializer.rb +++ b/app/serializers/activitypub/follow_serializer.rb @@ -1,12 +1,11 @@ # frozen_string_literal: true class ActivityPub::FollowSerializer < ActiveModel::Serializer - attributes :type, :actor - attribute :id, if: :dereferencable? + attributes :id, :type, :actor attribute :virtual_object, key: :object def id - ActivityPub::TagManager.instance.uri_for(object) + [ActivityPub::TagManager.instance.uri_for(object.account), '#follows/', object.id].join end def type @@ -20,8 +19,4 @@ class ActivityPub::FollowSerializer < ActiveModel::Serializer def virtual_object ActivityPub::TagManager.instance.uri_for(object.target_account) end - - def dereferencable? - object.respond_to?(:object_type) - end end diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index 4fa1981ed..904daa804 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -2,10 +2,15 @@ class InitialStateSerializer < ActiveModel::Serializer attributes :meta, :compose, :accounts, - :media_attachments, :settings, :push_subscription + :media_attachments, :settings, :push_subscription, + :max_toot_chars has_many :custom_emojis, serializer: REST::CustomEmojiSerializer + def max_toot_chars + StatusLengthValidator::MAX_CHARS + end + def custom_emojis CustomEmoji.local.where(disabled: false) end @@ -23,6 +28,7 @@ class InitialStateSerializer < ActiveModel::Serializer store[:me] = object.current_account.id.to_s store[:unfollow_modal] = object.current_account.user.setting_unfollow_modal store[:boost_modal] = object.current_account.user.setting_boost_modal + store[:favourite_modal] = object.current_account.user.setting_favourite_modal store[:delete_modal] = object.current_account.user.setting_delete_modal store[:auto_play_gif] = object.current_account.user.setting_auto_play_gif store[:reduce_motion] = object.current_account.user.setting_reduce_motion @@ -53,6 +59,6 @@ class InitialStateSerializer < ActiveModel::Serializer end def media_attachments - { accept_content_types: MediaAttachment::IMAGE_FILE_EXTENSIONS + MediaAttachment::VIDEO_FILE_EXTENSIONS + MediaAttachment::IMAGE_MIME_TYPES + MediaAttachment::VIDEO_MIME_TYPES } + { accept_content_types: MediaAttachment::IMAGE_FILE_EXTENSIONS + MediaAttachment::VIDEO_FILE_EXTENSIONS + MediaAttachment::AUDIO_FILE_EXTENSIONS + MediaAttachment::IMAGE_MIME_TYPES + MediaAttachment::VIDEO_MIME_TYPES + MediaAttachment::AUDIO_MIME_TYPES } end end diff --git a/app/serializers/manifest_serializer.rb b/app/serializers/manifest_serializer.rb index 95bcc21bb..859ef0d14 100644 --- a/app/serializers/manifest_serializer.rb +++ b/app/serializers/manifest_serializer.rb @@ -6,7 +6,8 @@ class ManifestSerializer < ActiveModel::Serializer attributes :name, :short_name, :description, :icons, :theme_color, :background_color, - :display, :start_url, :scope + :display, :start_url, :scope, + :share_target def name object.site_title @@ -49,4 +50,8 @@ class ManifestSerializer < ActiveModel::Serializer def scope root_url end + + def share_target + { url_template: 'share?title={title}&text={text}&url={url}' } + end end diff --git a/app/serializers/rest/instance_serializer.rb b/app/serializers/rest/instance_serializer.rb index ae1dbe6b5..65907dad2 100644 --- a/app/serializers/rest/instance_serializer.rb +++ b/app/serializers/rest/instance_serializer.rb @@ -4,7 +4,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer include RoutingHelper attributes :uri, :title, :description, :email, - :version, :urls, :stats, :thumbnail + :version, :urls, :stats, :thumbnail, :max_toot_chars def uri Rails.configuration.x.local_domain @@ -30,6 +30,10 @@ class REST::InstanceSerializer < ActiveModel::Serializer instance_presenter.thumbnail ? full_asset_url(instance_presenter.thumbnail.file.url) : full_pack_url('preview.jpg') end + def max_toot_chars + StatusLengthValidator::MAX_CHARS + end + def stats { user_count: instance_presenter.user_count, diff --git a/app/serializers/rest/mute_serializer.rb b/app/serializers/rest/mute_serializer.rb new file mode 100644 index 000000000..043a2f059 --- /dev/null +++ b/app/serializers/rest/mute_serializer.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class REST::MuteSerializer < ActiveModel::Serializer + include RoutingHelper + + attributes :id, :account, :target_account, :created_at, :hide_notifications + + def account + REST::AccountSerializer.new(object.account) + end + + def target_account + REST::AccountSerializer.new(object.target_account) + end +end \ No newline at end of file |