diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-07-29 18:17:51 -0500 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-07-29 18:17:51 -0500 |
commit | 0fb1e7888e8f2f83c8f1d6b19a44b6c079251a2e (patch) | |
tree | 8d33a54a5a23ac1776750922597ca17fc0fbb2bc | |
parent | 9d55cfc6addd0c6f6d3974fab3d66f09972d9fc5 (diff) |
actually let's make the delay time configurable
-rw-r--r-- | app/controllers/settings/preferences_controller.rb | 1 | ||||
-rw-r--r-- | app/lib/user_settings_decorator.rb | 5 | ||||
-rw-r--r-- | app/models/user.rb | 5 | ||||
-rw-r--r-- | app/services/post_status_service.rb | 3 | ||||
-rw-r--r-- | app/views/settings/preferences/show.html.haml | 1 | ||||
-rw-r--r-- | config/locales/simple_form.en.yml | 16 |
6 files changed, 29 insertions, 2 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/ diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index d56691bbe..8b9ea0bf5 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -118,7 +118,8 @@ en: setting_default_language: Posting language setting_default_privacy: Post privacy setting_roar_lifespan: Auto-delete new roars after - setting_delayed_roars: Delayed publishing of roars for proofreading (1 min) + setting_delayed_roars: Delayed publishing of roars for proofreading + setting_delayed_for: Delay for setting_default_local: Default to Monsterpit-only roars (in Glitch flavour) setting_always_local: Don't send your roars outside Monsterpit setting_rawr_federated: Show raw world timeline (may contain offensive content!) @@ -168,6 +169,19 @@ en: username: Username username_or_email: Username or Email whole_word: Whole word + delayed_for: + 5: 5 seconds + 10: 10 seconds + 15: 15 seconds + 30: 30 seconds + 60: 1 minute + 120: 2 minutes + 180: 3 minutes + 300: 5 minutes + 360: 6 minutes + 600: 10 minutes + 1800: 30 minutes + 3600: 1 hour lifespan: '0': No limit 1: 1 day |