Alternative handling of private self-boosts (#9998)
* When self-boosting, embed original toot into Announce serialization * Process unknown self-boosts from Announce object if it is more than an URI * Add some self-boost specs * Only serialize private toots in self-Announces
This commit is contained in:
		@@ -1,9 +1,6 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
class ActivityPub::Activity::Create < ActivityPub::Activity
 | 
			
		||||
  SUPPORTED_TYPES = %w(Note).freeze
 | 
			
		||||
  CONVERTED_TYPES = %w(Image Video Article Page).freeze
 | 
			
		||||
 | 
			
		||||
  def perform
 | 
			
		||||
    return if unsupported_object_type? || invalid_origin?(@object['id'])
 | 
			
		||||
    return if Tombstone.exists?(uri: @object['id'])
 | 
			
		||||
@@ -318,22 +315,10 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
 | 
			
		||||
    @object['nameMap'].is_a?(Hash) && !@object['nameMap'].empty?
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def unsupported_object_type?
 | 
			
		||||
    @object.is_a?(String) || !(supported_object_type? || converted_object_type?)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def unsupported_media_type?(mime_type)
 | 
			
		||||
    mime_type.present? && !(MediaAttachment::IMAGE_MIME_TYPES + MediaAttachment::VIDEO_MIME_TYPES).include?(mime_type)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def supported_object_type?
 | 
			
		||||
    equals_or_includes_any?(@object['type'], SUPPORTED_TYPES)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def converted_object_type?
 | 
			
		||||
    equals_or_includes_any?(@object['type'], CONVERTED_TYPES)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def skip_download?
 | 
			
		||||
    return @skip_download if defined?(@skip_download)
 | 
			
		||||
    @skip_download ||= DomainBlock.find_by(domain: @account.domain)&.reject_media?
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user