Set snowflake IDs for backdated statuses (#5260)
- Rename Mastodon::TimestampIds into Mastodon::Snowflake for clarity - Skip for statuses coming from inbox, aka delivered in real-time - Skip for statuses that claim to be from the future
This commit is contained in:
		
							parent
							
								
									6e4046fc3f
								
							
						
					
					
						commit
						0717d9b3e6
					
				
					 16 changed files with 83 additions and 43 deletions
				
			
		| 
						 | 
				
			
			@ -3,9 +3,10 @@
 | 
			
		|||
class ActivityPub::ProcessCollectionService < BaseService
 | 
			
		||||
  include JsonLdHelper
 | 
			
		||||
 | 
			
		||||
  def call(body, account)
 | 
			
		||||
  def call(body, account, options = {})
 | 
			
		||||
    @account = account
 | 
			
		||||
    @json    = Oj.load(body, mode: :strict)
 | 
			
		||||
    @options = options
 | 
			
		||||
 | 
			
		||||
    return unless supported_context?
 | 
			
		||||
    return if different_actor? && verify_account!.nil?
 | 
			
		||||
| 
						 | 
				
			
			@ -38,7 +39,7 @@ class ActivityPub::ProcessCollectionService < BaseService
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def process_item(item)
 | 
			
		||||
    activity = ActivityPub::Activity.factory(item, @account)
 | 
			
		||||
    activity = ActivityPub::Activity.factory(item, @account, @options)
 | 
			
		||||
    activity&.perform
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,9 @@
 | 
			
		|||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
class ProcessFeedService < BaseService
 | 
			
		||||
  def call(body, account)
 | 
			
		||||
  def call(body, account, options = {})
 | 
			
		||||
    @options = options
 | 
			
		||||
 | 
			
		||||
    xml = Nokogiri::XML(body)
 | 
			
		||||
    xml.encoding = 'utf-8'
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -20,7 +22,7 @@ class ProcessFeedService < BaseService
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def process_entry(xml, account)
 | 
			
		||||
    activity = OStatus::Activity::General.new(xml, account)
 | 
			
		||||
    activity = OStatus::Activity::General.new(xml, account, @options)
 | 
			
		||||
    activity.specialize&.perform if activity.status?
 | 
			
		||||
  rescue ActiveRecord::RecordInvalid => e
 | 
			
		||||
    Rails.logger.debug "Nothing was saved for #{activity.id} because: #{e}"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in a new issue