Add QT attribute to send as quote
This commit is contained in:
parent
d257157276
commit
e16a885c81
3 changed files with 10 additions and 8 deletions
|
@ -226,6 +226,10 @@ class Status < ApplicationRecord
|
||||||
!reblog_of_id.nil?
|
!reblog_of_id.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def quote
|
||||||
|
reference_objects.where(attribute_type: 'QT').first&.target_status
|
||||||
|
end
|
||||||
|
|
||||||
def within_realtime_window?
|
def within_realtime_window?
|
||||||
created_at >= REAL_TIME_WINDOW.ago
|
created_at >= REAL_TIME_WINDOW.ago
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,6 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
|
||||||
|
|
||||||
attribute :quote_uri, if: :quote?
|
attribute :quote_uri, if: :quote?
|
||||||
attribute :misskey_quote, key: :_misskey_quote, if: :quote?
|
attribute :misskey_quote, key: :_misskey_quote, if: :quote?
|
||||||
attribute :misskey_content, key: :_misskey_content, if: :quote?
|
|
||||||
|
|
||||||
has_many :virtual_attachments, key: :attachment
|
has_many :virtual_attachments, key: :attachment
|
||||||
has_many :virtual_tags, key: :tag
|
has_many :virtual_tags, key: :tag
|
||||||
|
@ -172,21 +171,21 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def quote?
|
def quote?
|
||||||
object.references.count == 1 && object.account.user&.settings&.[]('single_ref_to_quote')
|
@quote ||= (object.reference_objects.count == 1 && object.account.user&.settings&.[]('single_ref_to_quote')) || object.reference_objects.where(attribute_type: 'QT').count == 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def quote_post
|
||||||
|
@quote_post ||= object.quote || object.references.first
|
||||||
end
|
end
|
||||||
|
|
||||||
def quote_uri
|
def quote_uri
|
||||||
ActivityPub::TagManager.instance.uri_for(object.references.first)
|
ActivityPub::TagManager.instance.uri_for(quote_post)
|
||||||
end
|
end
|
||||||
|
|
||||||
def misskey_quote
|
def misskey_quote
|
||||||
quote_uri
|
quote_uri
|
||||||
end
|
end
|
||||||
|
|
||||||
def misskey_content
|
|
||||||
object.text
|
|
||||||
end
|
|
||||||
|
|
||||||
def poll_options
|
def poll_options
|
||||||
object.preloadable_poll.loaded_options
|
object.preloadable_poll.loaded_options
|
||||||
end
|
end
|
||||||
|
|
|
@ -73,7 +73,6 @@ describe ActivityPub::NoteSerializer do
|
||||||
expect(subject['quoteUri']).to_not be_nil
|
expect(subject['quoteUri']).to_not be_nil
|
||||||
expect(subject['quoteUri']).to eq referred.uri
|
expect(subject['quoteUri']).to eq referred.uri
|
||||||
expect(subject['_misskey_quote']).to eq referred.uri
|
expect(subject['_misskey_quote']).to eq referred.uri
|
||||||
expect(subject['_misskey_content']).to eq referred.text
|
|
||||||
expect(subject['references']['first']['items']).to include referred.uri
|
expect(subject['references']['first']['items']).to include referred.uri
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue