diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-07-29 14:26:41 -0500 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-07-29 14:26:41 -0500 |
commit | 74290d4eb3f6771ad21d9e2c1d0a76d4f76bb263 (patch) | |
tree | a6309badafe748d3a0269d23a00411c8586299d3 /app/services | |
parent | 02729ab3ae3f5a59b6c9b84bd24282e9a003e3d2 (diff) |
optional delayed publishing of roars for proofreading
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/fan_out_on_write_service.rb | 3 | ||||
-rw-r--r-- | app/services/post_status_service.rb | 22 |
2 files changed, 21 insertions, 4 deletions
diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb index 235c156f5..b1db23acd 100644 --- a/app/services/fan_out_on_write_service.rb +++ b/app/services/fan_out_on_write_service.rb @@ -3,10 +3,11 @@ class FanOutOnWriteService < BaseService # Push a status into home and mentions feeds # @param [Status] status - def call(status) + def call(status, delayed = false) raise Mastodon::RaceConditionError if status.visibility.nil? deliver_to_self(status) if status.account.local? + return if delayed render_anonymous_payload(status) diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index b24ca02b3..144cc19c9 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -32,6 +32,7 @@ class PostStatusService < BaseService # @option [String] :delete_after # @option [Boolean] :nocrawl Optional skip link card generation # @option [Boolean] :nomentions Optional skip mention processing + # @option [Boolean] :delayed Optional publishing delay of 30 secs # @option [Hash] :poll Optional poll to attach # @option [Enumerable] :media_ids Optional array of media IDs to attach # @option [Doorkeeper::Application] :application @@ -57,8 +58,23 @@ class PostStatusService < BaseService schedule_status! else return unless process_status! - postprocess_status! - bump_potential_friendship! + if @options[:delayed] || @account&.user&.delayed_roars? + delay_until = Time.now.utc + 30.seconds + opts = { + visibility: @visibility, + federate: @options[:federate], + distribute: @options[:distribute], + nocrawl: @options[:nocrawl], + nomentions: @options[:nomentions], + delete_after: @delete_after.nil? ? nil : @delete_after + 30.seconds, + }.compact + + PostStatusWorker.perform_at(delay_until, @status.id, opts) + DistributionWorker.perform_async(@status.id, delayed = true) unless @options[:distribute] == false + else + postprocess_status! + bump_potential_friendship! + end end redis.setex(idempotency_key, 3_600, @status.id) if idempotency_given? @@ -149,7 +165,7 @@ class PostStatusService < BaseService return false if @status.destroyed? process_hashtags_service.call(@status, @tags, @preloaded_tags) - process_mentions_service.call(@status) unless @options[:nomentions] + process_mentions_service.call(@status) unless @delayed || @options[:nomentions] return true end |