Merge remote-tracking branch 'accelforce/custom/quote' into features/v4.1.2
This commit is contained in:
@@ -11,6 +11,9 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
|
||||
:atom_uri, :in_reply_to_atom_uri,
|
||||
:conversation
|
||||
|
||||
attribute :quote_url, if: -> { object.quote? }
|
||||
attribute :misskey_quote, key: :_misskey_quote, if: -> { object.quote? }
|
||||
attribute :misskey_content, key: :_misskey_content, if: -> { object.quote? }
|
||||
attribute :content
|
||||
attribute :content_map, if: :language?
|
||||
attribute :updated, if: :edited?
|
||||
@@ -138,6 +141,16 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
|
||||
end
|
||||
end
|
||||
|
||||
def quote_url
|
||||
ActivityPub::TagManager.instance.uri_for(object.quote) if object.quote?
|
||||
end
|
||||
|
||||
alias misskey_quote quote_url
|
||||
|
||||
def misskey_content
|
||||
object.text if object.quote?
|
||||
end
|
||||
|
||||
def local?
|
||||
object.account.local?
|
||||
end
|
||||
|
@@ -11,7 +11,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
||||
|
||||
attributes :domain, :title, :version, :source_url, :description,
|
||||
:usage, :thumbnail, :languages, :configuration,
|
||||
:registrations
|
||||
:registrations, :feature_quote
|
||||
|
||||
has_one :contact, serializer: ContactSerializer
|
||||
has_many :rules, serializer: REST::RuleSerializer
|
||||
@@ -88,6 +88,10 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
||||
}
|
||||
end
|
||||
|
||||
def feature_quote
|
||||
true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def registrations_enabled?
|
||||
|
@@ -18,6 +18,8 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
attribute :content, unless: :source_requested?
|
||||
attribute :text, if: :source_requested?
|
||||
|
||||
attribute :quote_id, if: -> { object.quote? }
|
||||
|
||||
belongs_to :reblog, serializer: REST::StatusSerializer
|
||||
belongs_to :application, if: :show_application?
|
||||
belongs_to :account, serializer: REST::AccountSerializer
|
||||
@@ -42,6 +44,10 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
object.in_reply_to_account_id&.to_s
|
||||
end
|
||||
|
||||
def quote_id
|
||||
object.quote_id.to_s
|
||||
end
|
||||
|
||||
def current_user?
|
||||
!current_user.nil?
|
||||
end
|
||||
@@ -182,3 +188,26 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class REST::NestedQuoteSerializer < REST::StatusSerializer
|
||||
attribute :quote do
|
||||
nil
|
||||
end
|
||||
attribute :quote_muted, if: :current_user?
|
||||
|
||||
def quote_muted
|
||||
if instance_options && instance_options[:account_relationships]
|
||||
!!instance_options[:account_relationships].muting[object.account_id] ||
|
||||
instance_options[:account_relationships].blocking[object.account_id] ||
|
||||
instance_options[:account_relationships].blocked_by[object.account_id] ||
|
||||
instance_options[:account_relationships].domain_blocking[object.account_id]
|
||||
else
|
||||
current_user.account.muting?(object.account) || object.account.blocking?(current_user.account) || current_user.account.blocking?(object.account) || current_user.account.domain_blocking?(object.account.domain)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class REST::StatusSerializer < ActiveModel::Serializer
|
||||
belongs_to :quote, serializer: REST::NestedQuoteSerializer
|
||||
end
|
||||
|
Reference in New Issue
Block a user