about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/settings/preferences_controller.rb1
-rw-r--r--app/javascript/flavours/glitch/reducers/compose.js4
-rw-r--r--app/javascript/mastodon/initial_state.js1
-rw-r--r--app/lib/user_settings_decorator.rb5
-rw-r--r--app/models/user.rb6
-rw-r--r--app/serializers/initial_state_serializer.rb1
-rw-r--r--app/views/settings/preferences/show.html.haml1
-rw-r--r--config/locales/simple_form.en.yml1
8 files changed, 17 insertions, 3 deletions
diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb
index 3d98d583c..c75528ce4 100644
--- a/app/controllers/settings/preferences_controller.rb
+++ b/app/controllers/settings/preferences_controller.rb
@@ -30,6 +30,7 @@ class Settings::PreferencesController < Settings::BaseController
   def user_settings_params
     params.require(:user).permit(
       :setting_default_privacy,
+      :setting_default_local,
       :setting_default_sensitive,
       :setting_default_language,
       :setting_unfollow_modal,
diff --git a/app/javascript/flavours/glitch/reducers/compose.js b/app/javascript/flavours/glitch/reducers/compose.js
index 094b7d476..8bb1aa642 100644
--- a/app/javascript/flavours/glitch/reducers/compose.js
+++ b/app/javascript/flavours/glitch/reducers/compose.js
@@ -45,7 +45,7 @@ import { REDRAFT } from 'flavours/glitch/actions/statuses';
 import { Map as ImmutableMap, List as ImmutableList, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable';
 import uuid from 'flavours/glitch/util/uuid';
 import { privacyPreference } from 'flavours/glitch/util/privacy_preference';
-import { me, defaultContentType } from 'flavours/glitch/util/initial_state';
+import { me, defaultContentType, defaultLocal } from 'flavours/glitch/util/initial_state';
 import { overwrite } from 'flavours/glitch/util/js_helpers';
 import { unescapeHTML } from 'flavours/glitch/util/html';
 import { recoverHashtags } from 'flavours/glitch/util/hashtag';
@@ -59,7 +59,7 @@ const glitchProbability = 1 - 0.0420215528;
 const initialState = ImmutableMap({
   mounted: false,
   advanced_options: ImmutableMap({
-    do_not_federate: false,
+    do_not_federate: defaultLocal,
     threaded_mode: false,
   }),
   sensitive: false,
diff --git a/app/javascript/mastodon/initial_state.js b/app/javascript/mastodon/initial_state.js
index d74f5ceb1..ac8e51938 100644
--- a/app/javascript/mastodon/initial_state.js
+++ b/app/javascript/mastodon/initial_state.js
@@ -11,6 +11,7 @@ export const unfollowModal = getMeta('unfollow_modal');
 export const boostModal = getMeta('boost_modal');
 export const deleteModal = getMeta('delete_modal');
 export const me = getMeta('me');
+export const defaultLocal = getMeta('default_local');
 export const searchEnabled = getMeta('search_enabled');
 export const maxChars = (initialState && initialState.max_toot_chars) || 500;
 export const invitesEnabled = getMeta('invites_enabled');
diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb
index 802ca71fe..9358dad68 100644
--- a/app/lib/user_settings_decorator.rb
+++ b/app/lib/user_settings_decorator.rb
@@ -18,6 +18,7 @@ class UserSettingsDecorator
     user.settings['notification_emails'] = merged_notification_emails if change?('notification_emails')
     user.settings['interactions']        = merged_interactions if change?('interactions')
     user.settings['default_privacy']     = default_privacy_preference if change?('setting_default_privacy')
+    user.settings['default_local']       = default_local_preference if change?('setting_default_local')
     user.settings['default_sensitive']   = default_sensitive_preference if change?('setting_default_sensitive')
     user.settings['default_language']    = default_language_preference if change?('setting_default_language')
     user.settings['unfollow_modal']      = unfollow_modal_preference if change?('setting_unfollow_modal')
@@ -51,6 +52,10 @@ class UserSettingsDecorator
     settings['setting_default_privacy']
   end
 
+  def default_local_preference
+    boolean_cast_setting 'setting_default_local'
+  end
+
   def default_sensitive_preference
     boolean_cast_setting 'setting_default_sensitive'
   end
diff --git a/app/models/user.rb b/app/models/user.rb
index b336921bc..b1da03d02 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -102,7 +102,7 @@ class User < ApplicationRecord
 
   has_many :session_activations, dependent: :destroy
 
-  delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :favourite_modal, :delete_modal,
+  delegate :auto_play_gif, :default_local, :default_sensitive, :unfollow_modal, :boost_modal, :favourite_modal, :delete_modal,
            :reduce_motion, :system_font_ui, :noindex, :flavour, :skin, :display_media, :hide_network, :hide_followers_count,
            :expand_spoilers, :default_language, :aggregate_reblogs, :show_application, :default_content_type, to: :settings, prefix: :setting, allow_nil: false
 
@@ -188,6 +188,10 @@ class User < ApplicationRecord
     settings.default_privacy || 'public'
   end
 
+  def setting_default_local
+    settings.default_local || false
+  end
+
   def allows_digest_emails?
     settings.notification_emails['digest']
   end
diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb
index d74e56ebc..6146ff32e 100644
--- a/app/serializers/initial_state_serializer.rb
+++ b/app/serializers/initial_state_serializer.rb
@@ -38,6 +38,7 @@ class InitialStateSerializer < ActiveModel::Serializer
 
     if object.current_account
       store[:me]              = object.current_account.id.to_s
+      store[:default_local]   = object.current_account.user.setting_default_local
       store[:unfollow_modal]  = object.current_account.user.setting_unfollow_modal
       store[:boost_modal]     = object.current_account.user.setting_boost_modal
       store[:favourite_modal] = object.current_account.user.setting_favourite_modal
diff --git a/app/views/settings/preferences/show.html.haml b/app/views/settings/preferences/show.html.haml
index cd5bf9be2..a55d427db 100644
--- a/app/views/settings/preferences/show.html.haml
+++ b/app/views/settings/preferences/show.html.haml
@@ -27,6 +27,7 @@
 
     = f.input :setting_default_content_type, collection: ['text/plain', 'text/markdown', 'text/html'], wrapper: :with_label, include_blank: false, label_method: lambda { |item| safe_join([t("simple_form.labels.defaults.setting_default_content_type_#{item.split('/')[1]}"), content_tag(:span, t("simple_form.hints.defaults.setting_default_content_type_#{item.split('/')[1]}"), class: 'hint')]) }, required: false, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li'
 
+    = f.input :setting_default_local, as: :boolean, wrapper: :with_label
     = f.input :setting_default_sensitive, as: :boolean, wrapper: :with_label
 
   %hr#settings_other/
diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml
index 7be9622a7..df5f4d3c6 100644
--- a/config/locales/simple_form.en.yml
+++ b/config/locales/simple_form.en.yml
@@ -102,6 +102,7 @@ en:
         setting_default_content_type_plain: Plain text
         setting_default_language: Posting language
         setting_default_privacy: Post privacy
+        setting_default_local: Default to local only
         setting_default_sensitive: Always mark media as sensitive
         setting_delete_modal: Show confirmation dialog before deleting a roar
         setting_display_media: Media display