about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/settings/preferences_controller.rb1
-rw-r--r--app/lib/user_settings_decorator.rb5
-rw-r--r--app/models/user.rb5
-rw-r--r--app/services/post_status_service.rb3
-rw-r--r--app/views/settings/preferences/show.html.haml1
5 files changed, 14 insertions, 1 deletions
diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb
index 0e5b0f536..12bea3ec3 100644
--- a/app/controllers/settings/preferences_controller.rb
+++ b/app/controllers/settings/preferences_controller.rb
@@ -55,6 +55,7 @@ class Settings::PreferencesController < Settings::BaseController
       :setting_max_public_history,
       :setting_roar_lifespan,
       :setting_delayed_roars,
+      :setting_delayed_for,
 
       :setting_default_privacy,
       :setting_default_sensitive,
diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb
index 801a71bc4..5aedf3a1c 100644
--- a/app/lib/user_settings_decorator.rb
+++ b/app/lib/user_settings_decorator.rb
@@ -39,6 +39,7 @@ class UserSettingsDecorator
     user.settings['max_public_history']  = max_public_history_preference if change?('setting_max_public_history')
     user.settings['roar_lifespan']       = roar_lifespan_preference if change?('setting_roar_lifespan')
     user.settings['delayed_roars']       = delayed_roars_preference if change?('setting_delayed_roars')
+    user.settings['delayed_for']         = delayed_for_preference if change?('setting_delayed_for')
 
     user.settings['notification_emails'] = merged_notification_emails if change?('notification_emails')
     user.settings['interactions']        = merged_interactions if change?('interactions')
@@ -136,6 +137,10 @@ class UserSettingsDecorator
     settings['setting_roar_lifespan']
   end
 
+  def delayed_for_preference
+    settings['setting_delayed_for']
+  end
+
   def delayed_roars_preference
     settings['setting_delayed_roars']
   end
diff --git a/app/models/user.rb b/app/models/user.rb
index 3ca019cb9..c14c33567 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -127,6 +127,7 @@ class User < ApplicationRecord
     :max_public_history,
     :roar_lifespan,
     :delayed_roars,
+    :delayed_for,
 
     :auto_play_gif,
     :default_sensitive,
@@ -309,6 +310,10 @@ class User < ApplicationRecord
     @delayed_roars ||= (settings.delayed_roars || false)
   end
 
+  def delayed_for
+    @_delayed_for ||= (settings.delayed_for || 60)
+  end
+
   def defaults_to_local_only?
     @defaults_to_local_only ||= (settings.default_local || false)
   end
diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb
index a61a4f756..e8f785db5 100644
--- a/app/services/post_status_service.rb
+++ b/app/services/post_status_service.rb
@@ -59,7 +59,8 @@ class PostStatusService < BaseService
     else
       return unless process_status!
       if @options[:delayed] || @account&.user&.delayed_roars?
-        delay_until = Time.now.utc + 1.minute
+        delay_for = [5, @account&.user&.delayed_for.to_i].max
+        delay_until = Time.now.utc + delay_for.seconds
         opts = {
           visibility: @visibility,
           local_only: @local_only,
diff --git a/app/views/settings/preferences/show.html.haml b/app/views/settings/preferences/show.html.haml
index f1e9656b6..47c3d6915 100644
--- a/app/views/settings/preferences/show.html.haml
+++ b/app/views/settings/preferences/show.html.haml
@@ -33,6 +33,7 @@
 
   .fields-group
     = f.input :setting_delayed_roars, as: :boolean, wrapper: :with_label
+    = f.input :setting_delayed_for, collection: [5, 10, 15, 30, 60, 120, 180, 300, 360, 600, 1800, 3600], wrapper: :with_label, include_blank: false, label_method: lambda { |item| safe_join([t("simple_form.labels.delayed_for.#{item}")]) }, selected: [5, current_user.delayed_for.to_i].max
 
   %hr#settings_other/