Merge tag 'v3.0.0' into hometown-dev
This commit is contained in:
@ -5,7 +5,7 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||
|
||||
attributes :id, :username, :acct, :display_name, :locked, :bot, :created_at,
|
||||
:note, :url, :avatar, :avatar_static, :header, :header_static,
|
||||
:followers_count, :following_count, :statuses_count
|
||||
:followers_count, :following_count, :statuses_count, :last_status_at
|
||||
|
||||
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
|
||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
||||
@ -29,7 +29,7 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def url
|
||||
TagManager.instance.url_for(object)
|
||||
ActivityPub::TagManager.instance.url_for(object)
|
||||
end
|
||||
|
||||
def avatar
|
||||
|
@ -13,6 +13,7 @@ class REST::CredentialAccountSerializer < REST::AccountSerializer
|
||||
federation: user.setting_default_federation,
|
||||
note: object.note,
|
||||
fields: object.fields.map(&:to_h),
|
||||
follow_requests_count: FollowRequest.where(target_account: object).limit(40).count,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -5,6 +5,8 @@ class REST::CustomEmojiSerializer < ActiveModel::Serializer
|
||||
|
||||
attributes :shortcode, :url, :static_url, :visible_in_picker
|
||||
|
||||
attribute :category, if: :category_loaded?
|
||||
|
||||
def url
|
||||
full_asset_url(object.image.url)
|
||||
end
|
||||
@ -12,4 +14,12 @@ class REST::CustomEmojiSerializer < ActiveModel::Serializer
|
||||
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
|
||||
end
|
||||
|
9
app/serializers/rest/featured_tag_serializer.rb
Normal file
9
app/serializers/rest/featured_tag_serializer.rb
Normal file
@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::FeaturedTagSerializer < ActiveModel::Serializer
|
||||
attributes :id, :name, :statuses_count, :last_status_at
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
end
|
13
app/serializers/rest/marker_serializer.rb
Normal file
13
app/serializers/rest/marker_serializer.rb
Normal file
@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::MarkerSerializer < ActiveModel::Serializer
|
||||
attributes :last_read_id, :version, :updated_at
|
||||
|
||||
def last_read_id
|
||||
object.last_read_id.to_s
|
||||
end
|
||||
|
||||
def version
|
||||
object.lock_version
|
||||
end
|
||||
end
|
@ -2,12 +2,13 @@
|
||||
|
||||
class REST::PollSerializer < ActiveModel::Serializer
|
||||
attributes :id, :expires_at, :expired,
|
||||
:multiple, :votes_count
|
||||
:multiple, :votes_count, :voters_count
|
||||
|
||||
has_many :loaded_options, key: :options
|
||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
||||
|
||||
attribute :voted, if: :current_user?
|
||||
attribute :own_votes, if: :current_user?
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
@ -21,6 +22,10 @@ class REST::PollSerializer < ActiveModel::Serializer
|
||||
object.voted?(current_user.account)
|
||||
end
|
||||
|
||||
def own_votes
|
||||
object.own_votes(current_user.account)
|
||||
end
|
||||
|
||||
def current_user?
|
||||
!current_user.nil?
|
||||
end
|
||||
|
@ -1,12 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::SearchSerializer < ActiveModel::Serializer
|
||||
attributes :hashtags
|
||||
|
||||
has_many :accounts, serializer: REST::AccountSerializer
|
||||
has_many :statuses, serializer: REST::StatusSerializer
|
||||
|
||||
def hashtags
|
||||
object.hashtags.map(&:name)
|
||||
end
|
||||
has_many :hashtags, serializer: REST::TagSerializer
|
||||
end
|
||||
|
@ -58,7 +58,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def uri
|
||||
OStatus::TagManager.instance.uri_for(object)
|
||||
ActivityPub::TagManager.instance.uri_for(object)
|
||||
end
|
||||
|
||||
def activity_pub_type
|
||||
@ -70,7 +70,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def url
|
||||
TagManager.instance.url_for(object)
|
||||
ActivityPub::TagManager.instance.url_for(object)
|
||||
end
|
||||
|
||||
def favourited
|
||||
@ -136,7 +136,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def url
|
||||
TagManager.instance.url_for(object.account)
|
||||
ActivityPub::TagManager.instance.url_for(object.account)
|
||||
end
|
||||
|
||||
def acct
|
||||
|
@ -1,7 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::V2::SearchSerializer < ActiveModel::Serializer
|
||||
has_many :accounts, serializer: REST::AccountSerializer
|
||||
has_many :statuses, serializer: REST::StatusSerializer
|
||||
has_many :hashtags, serializer: REST::TagSerializer
|
||||
end
|
Reference in New Issue
Block a user