Refactor all ActivityPub deliveries to be serialized and signed through one concern (#10966)
This commit is contained in:
		@@ -2,6 +2,7 @@
 | 
			
		||||
 | 
			
		||||
class ActivityPub::DistributionWorker
 | 
			
		||||
  include Sidekiq::Worker
 | 
			
		||||
  include Payloadable
 | 
			
		||||
 | 
			
		||||
  sidekiq_options queue: 'push'
 | 
			
		||||
 | 
			
		||||
@@ -41,20 +42,8 @@ class ActivityPub::DistributionWorker
 | 
			
		||||
                 end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def signed_payload
 | 
			
		||||
    Oj.dump(ActivityPub::LinkedDataSignature.new(unsigned_payload).sign!(@account))
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def unsigned_payload
 | 
			
		||||
    ActiveModelSerializers::SerializableResource.new(
 | 
			
		||||
      @status,
 | 
			
		||||
      serializer: ActivityPub::ActivitySerializer,
 | 
			
		||||
      adapter: ActivityPub::Adapter
 | 
			
		||||
    ).as_json
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def payload
 | 
			
		||||
    @payload ||= @status.distributable? ? signed_payload : Oj.dump(unsigned_payload)
 | 
			
		||||
    @payload ||= Oj.dump(serialize_payload(@status, ActivityPub::ActivitySerializer, signer: @account))
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def relay!
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user