Merge tag 'v2.8.0' into instance_only_statuses
This commit is contained in:
17
app/serializers/rest/identity_proof_serializer.rb
Normal file
17
app/serializers/rest/identity_proof_serializer.rb
Normal file
@ -0,0 +1,17 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::IdentityProofSerializer < ActiveModel::Serializer
|
||||
attributes :provider, :provider_username, :updated_at, :proof_url, :profile_url
|
||||
|
||||
def proof_url
|
||||
object.badge.proof_url
|
||||
end
|
||||
|
||||
def profile_url
|
||||
object.badge.profile_url
|
||||
end
|
||||
|
||||
def provider
|
||||
object.provider.capitalize
|
||||
end
|
||||
end
|
@ -32,7 +32,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def thumbnail
|
||||
instance_presenter.thumbnail ? full_asset_url(instance_presenter.thumbnail.file.url) : full_pack_url('preview.jpg')
|
||||
instance_presenter.thumbnail ? full_asset_url(instance_presenter.thumbnail.file.url) : full_pack_url('media/images/preview.jpg')
|
||||
end
|
||||
|
||||
def stats
|
||||
@ -52,7 +52,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def registrations
|
||||
Setting.open_registrations && !Rails.configuration.x.single_user_mode
|
||||
Setting.registrations_mode != 'none' && !Rails.configuration.x.single_user_mode
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -11,6 +11,6 @@ class REST::NotificationSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def status_type?
|
||||
[:favourite, :reblog, :mention].include?(object.type)
|
||||
[:favourite, :reblog, :mention, :poll].include?(object.type)
|
||||
end
|
||||
end
|
||||
|
31
app/serializers/rest/poll_serializer.rb
Normal file
31
app/serializers/rest/poll_serializer.rb
Normal file
@ -0,0 +1,31 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::PollSerializer < ActiveModel::Serializer
|
||||
attributes :id, :expires_at, :expired,
|
||||
:multiple, :votes_count
|
||||
|
||||
has_many :loaded_options, key: :options
|
||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
||||
|
||||
attribute :voted, if: :current_user?
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def expired
|
||||
object.expired?
|
||||
end
|
||||
|
||||
def voted
|
||||
object.voted?(current_user.account)
|
||||
end
|
||||
|
||||
def current_user?
|
||||
!current_user.nil?
|
||||
end
|
||||
|
||||
class OptionSerializer < ActiveModel::Serializer
|
||||
attributes :title, :votes_count
|
||||
end
|
||||
end
|
30
app/serializers/rest/preferences_serializer.rb
Normal file
30
app/serializers/rest/preferences_serializer.rb
Normal file
@ -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
|
@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::RelationshipSerializer < ActiveModel::Serializer
|
||||
attributes :id, :following, :showing_reblogs, :followed_by, :blocking,
|
||||
attributes :id, :following, :showing_reblogs, :followed_by, :blocking, :blocked_by,
|
||||
:muting, :muting_notifications, :requested, :domain_blocking,
|
||||
:endorsed
|
||||
|
||||
@ -27,6 +27,10 @@ class REST::RelationshipSerializer < ActiveModel::Serializer
|
||||
instance_options[:relationships].blocking[object.id] || false
|
||||
end
|
||||
|
||||
def blocked_by
|
||||
instance_options[:relationships].blocked_by[object.id] || false
|
||||
end
|
||||
|
||||
def muting
|
||||
instance_options[:relationships].muting[object.id] ? true : false
|
||||
end
|
||||
|
@ -12,7 +12,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
attribute :pinned, if: :pinnable?
|
||||
|
||||
belongs_to :reblog, serializer: REST::StatusSerializer
|
||||
belongs_to :application
|
||||
belongs_to :application, if: :show_application?
|
||||
belongs_to :account, serializer: REST::AccountSerializer
|
||||
|
||||
has_many :media_attachments, serializer: REST::MediaAttachmentSerializer
|
||||
@ -21,6 +21,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
has_many :emojis, serializer: REST::CustomEmojiSerializer
|
||||
|
||||
has_one :preview_card, key: :card, serializer: REST::PreviewCardSerializer
|
||||
has_one :preloadable_poll, key: :poll, serializer: REST::PollSerializer
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
@ -38,6 +39,10 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
!current_user.nil?
|
||||
end
|
||||
|
||||
def show_application?
|
||||
object.account.user_shows_application? || (current_user? && current_user.account_id == object.account_id)
|
||||
end
|
||||
|
||||
def visibility
|
||||
# This visibility is masked behind "private"
|
||||
# to avoid API changes because there are no
|
||||
|
Reference in New Issue
Block a user