Merge commit '5a0483ed21
' into kb_migration
This commit is contained in:
commit
7b735921dc
26 changed files with 204 additions and 50 deletions
|
@ -13,36 +13,23 @@ class ActivityPub::FetchReferencesService < BaseService
|
|||
|
||||
def collection_items(collection_or_uri)
|
||||
collection = fetch_collection(collection_or_uri)
|
||||
return unless collection.is_a?(Hash) && collection['first'].present?
|
||||
return unless collection.is_a?(Hash)
|
||||
|
||||
all_items = []
|
||||
collection = fetch_collection(collection['first'])
|
||||
collection = fetch_collection(collection['first']) if collection['first'].present?
|
||||
return unless collection.is_a?(Hash)
|
||||
|
||||
while collection.is_a?(Hash)
|
||||
items = begin
|
||||
case collection['type']
|
||||
when 'Collection', 'CollectionPage'
|
||||
collection['items']
|
||||
when 'OrderedCollection', 'OrderedCollectionPage'
|
||||
collection['orderedItems']
|
||||
end
|
||||
end
|
||||
|
||||
break if items.blank?
|
||||
|
||||
all_items.concat(items)
|
||||
|
||||
break if all_items.size >= StatusReferenceValidator::LIMIT
|
||||
|
||||
collection = collection['next'].present? ? fetch_collection(collection['next']) : nil
|
||||
case collection['type']
|
||||
when 'Collection', 'CollectionPage'
|
||||
collection['items']
|
||||
when 'OrderedCollection', 'OrderedCollectionPage'
|
||||
collection['orderedItems']
|
||||
end
|
||||
|
||||
all_items
|
||||
end
|
||||
|
||||
def fetch_collection(collection_or_uri)
|
||||
return collection_or_uri if collection_or_uri.is_a?(Hash)
|
||||
return if invalid_origin?(collection_or_uri)
|
||||
return if unsupported_uri_scheme?(collection_or_uri)
|
||||
return if ActivityPub::TagManager.instance.local_uri?(collection_or_uri)
|
||||
|
||||
fetch_resource_without_id_validation(collection_or_uri, nil, true)
|
||||
end
|
||||
|
|
|
@ -45,6 +45,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
|||
create_edits!
|
||||
end
|
||||
|
||||
update_references!
|
||||
download_media_files!
|
||||
queue_poll_notifications!
|
||||
|
||||
|
@ -240,6 +241,13 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
|||
end
|
||||
end
|
||||
|
||||
def update_references!
|
||||
references = @json['references'].nil? ? [] : ActivityPub::FetchReferencesService.new.call(@status, @json['references'])
|
||||
quote = @json['quote'] || @json['quoteUrl'] || @json['quoteURL'] || @json['_misskey_quote']
|
||||
references << quote if quote
|
||||
ProcessReferencesWorker.perform_async(@status.id, [], references)
|
||||
end
|
||||
|
||||
def expected_type?
|
||||
equals_or_includes_any?(@json['type'], %w(Note Question))
|
||||
end
|
||||
|
|
|
@ -76,6 +76,7 @@ class PostStatusService < BaseService
|
|||
@visibility = :unlisted if (@visibility&.to_sym == :public || @visibility&.to_sym == :public_unlisted || @visibility&.to_sym == :login) && @account.silenced?
|
||||
@visibility = :public_unlisted if @visibility&.to_sym == :public && !@options[:force_visibility] && !@options[:application]&.superapp && @account.user&.setting_public_post_to_unlisted
|
||||
@searchability = searchability
|
||||
@searchability = :private if @account.silenced? && @searchability&.to_sym == :public
|
||||
@markdown = @options[:markdown] || false
|
||||
@scheduled_at = @options[:scheduled_at]&.to_datetime
|
||||
@scheduled_at = nil if scheduled_in_the_past?
|
||||
|
|
|
@ -68,6 +68,8 @@ class ProcessReferencesService < BaseService
|
|||
end
|
||||
|
||||
def create_notifications!
|
||||
return if @added_objects.blank?
|
||||
|
||||
local_reference_objects = @added_objects.filter { |ref| ref.target_status.account.local? }
|
||||
return if local_reference_objects.empty?
|
||||
|
||||
|
@ -80,6 +82,7 @@ class ProcessReferencesService < BaseService
|
|||
return if removed_references.empty?
|
||||
|
||||
statuses = Status.where(id: removed_references)
|
||||
|
||||
@status.reference_objects.where(target_status: statuses).destroy_all
|
||||
statuses.each do |status|
|
||||
status.decrement_count!(:status_referred_by_count)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue