Remove custom_emoji aliases property from part of rest api
This commit is contained in:
parent
7e40c6ca4d
commit
01fcf84604
6 changed files with 57 additions and 51 deletions
|
@ -11,7 +11,7 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
|
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
|
||||||
|
|
||||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
has_many :emojis, serializer: REST::CustomEmojiSlimSerializer
|
||||||
|
|
||||||
attribute :suspended, if: :suspended?
|
attribute :suspended, if: :suspended?
|
||||||
attribute :silenced, key: :limited, if: :silenced?
|
attribute :silenced, key: :limited, if: :silenced?
|
||||||
|
|
|
@ -1,57 +1,11 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class REST::CustomEmojiSerializer < ActiveModel::Serializer
|
class REST::CustomEmojiSerializer < REST::CustomEmojiSlimSerializer
|
||||||
include RoutingHelper
|
include RoutingHelper
|
||||||
|
|
||||||
attributes :shortcode, :url, :static_url, :visible_in_picker
|
|
||||||
|
|
||||||
attribute :category, if: :category_loaded?
|
|
||||||
attribute :width, if: :width?
|
|
||||||
attribute :height, if: :height?
|
|
||||||
attribute :aliases, if: :aliases?
|
attribute :aliases, if: :aliases?
|
||||||
attribute :sensitive, if: :sensitive?
|
|
||||||
|
|
||||||
def url
|
|
||||||
full_asset_url(object.image.url)
|
|
||||||
end
|
|
||||||
|
|
||||||
def static_url
|
|
||||||
full_asset_url(object.image.url(:static))
|
|
||||||
end
|
|
||||||
|
|
||||||
def category
|
|
||||||
object.category.name
|
|
||||||
end
|
|
||||||
|
|
||||||
def category_loaded?
|
|
||||||
object.association(:category).loaded? && object.category.present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def width?
|
|
||||||
object.respond_to?(:image_width) || object.respond_to?(:width)
|
|
||||||
end
|
|
||||||
|
|
||||||
def height?
|
|
||||||
object.respond_to?(:image_height) || object.respond_to?(:height)
|
|
||||||
end
|
|
||||||
|
|
||||||
def width
|
|
||||||
object.respond_to?(:image_width) ? object.image_width : object.width
|
|
||||||
end
|
|
||||||
|
|
||||||
def height
|
|
||||||
object.respond_to?(:image_height) ? object.image_height : object.height
|
|
||||||
end
|
|
||||||
|
|
||||||
def aliases?
|
def aliases?
|
||||||
object.respond_to?(:aliases) && object.aliases.present?
|
object.respond_to?(:aliases) && object.aliases.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def sensitive?
|
|
||||||
object.respond_to?(:is_sensitive)
|
|
||||||
end
|
|
||||||
|
|
||||||
def sensitive
|
|
||||||
object.is_sensitive
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
52
app/serializers/rest/custom_emoji_slim_serializer.rb
Normal file
52
app/serializers/rest/custom_emoji_slim_serializer.rb
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class REST::CustomEmojiSlimSerializer < ActiveModel::Serializer
|
||||||
|
include RoutingHelper
|
||||||
|
|
||||||
|
attributes :shortcode, :url, :static_url, :visible_in_picker
|
||||||
|
|
||||||
|
attribute :category, if: :category_loaded?
|
||||||
|
attribute :width, if: :width?
|
||||||
|
attribute :height, if: :height?
|
||||||
|
attribute :sensitive, if: :sensitive?
|
||||||
|
|
||||||
|
def url
|
||||||
|
full_asset_url(object.image.url)
|
||||||
|
end
|
||||||
|
|
||||||
|
def static_url
|
||||||
|
full_asset_url(object.image.url(:static))
|
||||||
|
end
|
||||||
|
|
||||||
|
def category
|
||||||
|
object.category.name
|
||||||
|
end
|
||||||
|
|
||||||
|
def category_loaded?
|
||||||
|
object.association(:category).loaded? && object.category.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def width?
|
||||||
|
object.respond_to?(:image_width) || object.respond_to?(:width)
|
||||||
|
end
|
||||||
|
|
||||||
|
def height?
|
||||||
|
object.respond_to?(:image_height) || object.respond_to?(:height)
|
||||||
|
end
|
||||||
|
|
||||||
|
def width
|
||||||
|
object.respond_to?(:image_width) ? object.image_width : object.width
|
||||||
|
end
|
||||||
|
|
||||||
|
def height
|
||||||
|
object.respond_to?(:image_height) ? object.image_height : object.height
|
||||||
|
end
|
||||||
|
|
||||||
|
def sensitive?
|
||||||
|
object.respond_to?(:is_sensitive)
|
||||||
|
end
|
||||||
|
|
||||||
|
def sensitive
|
||||||
|
object.is_sensitive
|
||||||
|
end
|
||||||
|
end
|
|
@ -5,7 +5,7 @@ class REST::PollSerializer < ActiveModel::Serializer
|
||||||
:multiple, :votes_count, :voters_count
|
:multiple, :votes_count, :voters_count
|
||||||
|
|
||||||
has_many :loaded_options, key: :options
|
has_many :loaded_options, key: :options
|
||||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
has_many :emojis, serializer: REST::CustomEmojiSlimSerializer
|
||||||
|
|
||||||
attribute :voted, if: :current_user?
|
attribute :voted, if: :current_user?
|
||||||
attribute :own_votes, if: :current_user?
|
attribute :own_votes, if: :current_user?
|
||||||
|
|
|
@ -8,7 +8,7 @@ class REST::StatusEditSerializer < ActiveModel::Serializer
|
||||||
attributes :content, :spoiler_text, :markdown, :sensitive, :created_at
|
attributes :content, :spoiler_text, :markdown, :sensitive, :created_at
|
||||||
|
|
||||||
has_many :ordered_media_attachments, key: :media_attachments, serializer: REST::MediaAttachmentSerializer
|
has_many :ordered_media_attachments, key: :media_attachments, serializer: REST::MediaAttachmentSerializer
|
||||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
has_many :emojis, serializer: REST::CustomEmojiSlimSerializer
|
||||||
|
|
||||||
attribute :poll, if: -> { object.poll_options.present? }
|
attribute :poll, if: -> { object.poll_options.present? }
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||||
has_many :ordered_media_attachments, key: :media_attachments, serializer: REST::MediaAttachmentSerializer
|
has_many :ordered_media_attachments, key: :media_attachments, serializer: REST::MediaAttachmentSerializer
|
||||||
has_many :ordered_mentions, key: :mentions
|
has_many :ordered_mentions, key: :mentions
|
||||||
has_many :tags
|
has_many :tags
|
||||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
has_many :emojis, serializer: REST::CustomEmojiSlimSerializer
|
||||||
|
|
||||||
has_one :preview_card, key: :card, serializer: REST::PreviewCardSerializer
|
has_one :preview_card, key: :card, serializer: REST::PreviewCardSerializer
|
||||||
has_one :preloadable_poll, key: :poll, serializer: REST::PollSerializer
|
has_one :preloadable_poll, key: :poll, serializer: REST::PollSerializer
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue