From a680595ecb6b0d0fb1f8931585187f61c4e32874 Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Fri, 10 May 2019 10:49:27 -0500 Subject: `PostStatusService`: Add options to set a specific creation time and whether or not to distribute, useful for importing statuses. --- app/services/post_status_service.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app/services') diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 60a5cac5c..78b5fcbdb 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -11,6 +11,7 @@ class PostStatusService < BaseService # @option [String] :text Message # @option [Status] :thread Optional status to reply to # @option [Tag] :tags Optional tags to include + # @option [Time] :created_at Optional time which status was originally posted # @option [Boolean] :sensitive # @option [String] :visibility # @option [Boolean] :local_only @@ -107,9 +108,9 @@ class PostStatusService < BaseService def postprocess_status! LinkCrawlWorker.perform_async(@status.id) unless @status.spoiler_text? - DistributionWorker.perform_async(@status.id) + DistributionWorker.perform_async(@status.id) unless @options[:distribute] == false - unless @status.local_only? + unless @status.local_only? || @options[:distribute] == false || @options[:federate] == false ActivityPub::DistributionWorker.perform_async(@status.id) end @@ -175,6 +176,7 @@ class PostStatusService < BaseService def status_attributes { + created_at: @options[:created_at] ? @options[:created_at].to_datetime : Time.now.utc, text: @text, media_attachments: @media || [], thread: @in_reply_to, -- cgit