Add default federation option to settings
This commit is contained in:
parent
9d6e005849
commit
d42a06fc74
@ -33,6 +33,7 @@ class Api::V1::Accounts::CredentialsController < Api::BaseController
|
||||
'setting_default_privacy' => source_params.fetch(:privacy, @account.user.setting_default_privacy),
|
||||
'setting_default_sensitive' => source_params.fetch(:sensitive, @account.user.setting_default_sensitive),
|
||||
'setting_default_language' => source_params.fetch(:language, @account.user.setting_default_language),
|
||||
'setting_default_federation' => source_params.fetch(:sensitive, @account.user.setting_default_federation),
|
||||
}
|
||||
end
|
||||
end
|
||||
|
@ -36,6 +36,7 @@ class Settings::PreferencesController < ApplicationController
|
||||
:setting_default_privacy,
|
||||
:setting_default_sensitive,
|
||||
:setting_default_language,
|
||||
:setting_default_federation,
|
||||
:setting_unfollow_modal,
|
||||
:setting_boost_modal,
|
||||
:setting_delete_modal,
|
||||
|
@ -20,6 +20,7 @@ class UserSettingsDecorator
|
||||
user.settings['default_privacy'] = default_privacy_preference if change?('setting_default_privacy')
|
||||
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['default_federation'] = default_federation_preference if change?('setting_default_federation')
|
||||
user.settings['unfollow_modal'] = unfollow_modal_preference if change?('setting_unfollow_modal')
|
||||
user.settings['boost_modal'] = boost_modal_preference if change?('setting_boost_modal')
|
||||
user.settings['delete_modal'] = delete_modal_preference if change?('setting_delete_modal')
|
||||
@ -48,6 +49,10 @@ class UserSettingsDecorator
|
||||
boolean_cast_setting 'setting_default_sensitive'
|
||||
end
|
||||
|
||||
def default_federation_preference
|
||||
boolean_cast_setting 'setting_default_federation'
|
||||
end
|
||||
|
||||
def unfollow_modal_preference
|
||||
boolean_cast_setting 'setting_unfollow_modal'
|
||||
end
|
||||
|
@ -96,7 +96,7 @@ class User < ApplicationRecord
|
||||
|
||||
delegate :auto_play_gif, :default_sensitive, :unfollow_modal, :boost_modal, :delete_modal,
|
||||
:reduce_motion, :system_font_ui, :noindex, :theme, :display_sensitive_media, :hide_network,
|
||||
:default_language, to: :settings, prefix: :setting, allow_nil: false
|
||||
:default_language, :default_federation, to: :settings, prefix: :setting, allow_nil: false
|
||||
|
||||
attr_reader :invite_code
|
||||
|
||||
|
@ -38,6 +38,7 @@ class InitialStateSerializer < ActiveModel::Serializer
|
||||
store[:me] = object.current_account.id.to_s
|
||||
store[:default_privacy] = object.current_account.user.setting_default_privacy
|
||||
store[:default_sensitive] = object.current_account.user.setting_default_sensitive
|
||||
store[:default_federation] = object.current_account.user.setting_default_federation
|
||||
end
|
||||
|
||||
store[:text] = object.text if object.text
|
||||
|
@ -10,6 +10,7 @@ class REST::CredentialAccountSerializer < REST::AccountSerializer
|
||||
privacy: user.setting_default_privacy,
|
||||
sensitive: user.setting_default_sensitive,
|
||||
language: user.setting_default_language,
|
||||
federation: user.setting_default_federation,
|
||||
note: object.note,
|
||||
fields: object.fields.map(&:to_h),
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class PostStatusService < BaseService
|
||||
visibility: options[:visibility] || account.user&.setting_default_privacy,
|
||||
language: language_from_option(options[:language]) || account.user&.setting_default_language&.presence || LanguageDetector.instance.detect(text, account),
|
||||
application: options[:application],
|
||||
local_only: local_only_option(options[:local_only], in_reply_to))
|
||||
local_only: local_only_option(options[:local_only], in_reply_to, account.user&.setting_default_federation))
|
||||
end
|
||||
|
||||
process_hashtags_service.call(status)
|
||||
@ -58,8 +58,9 @@ class PostStatusService < BaseService
|
||||
|
||||
private
|
||||
|
||||
def local_only_option(local_only, in_reply_to)
|
||||
def local_only_option(local_only, in_reply_to, federation_setting)
|
||||
return in_reply_to&.local_only? if local_only.nil? # XXX temporary, just until clients implement to avoid leaking local_only posts
|
||||
return federation_setting if local_only.nil?
|
||||
local_only
|
||||
end
|
||||
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
= f.input :setting_default_sensitive, as: :boolean, wrapper: :with_label
|
||||
|
||||
= f.input :setting_default_federation, as: :boolean, wrapper: :with_label
|
||||
|
||||
%h4= t 'preferences.other'
|
||||
|
||||
.fields-group
|
||||
|
@ -65,6 +65,7 @@ en:
|
||||
phrase: Keyword or phrase
|
||||
setting_auto_play_gif: Auto-play animated GIFs
|
||||
setting_boost_modal: Show confirmation dialog before boosting
|
||||
setting_default_federation: Always allow my toots to reach other instances
|
||||
setting_default_language: Posting language
|
||||
setting_default_privacy: Post privacy
|
||||
setting_default_sensitive: Always mark media as sensitive
|
||||
|
@ -65,6 +65,7 @@ pt-BR:
|
||||
phrase: Palavra-chave ou frase
|
||||
setting_auto_play_gif: Reproduzir GIFs automaticamente
|
||||
setting_boost_modal: Mostrar diálogo de confirmação antes de compartilhar postagem
|
||||
setting_default_federation: Sempre permitir que meus toots cheguem em outras instâncias
|
||||
setting_default_language: Idioma das postagens
|
||||
setting_default_privacy: Privacidade das postagens
|
||||
setting_default_sensitive: Sempre marcar mídia como sensível
|
||||
|
@ -21,6 +21,7 @@ defaults: &defaults
|
||||
timeline_preview: true
|
||||
show_staff_badge: true
|
||||
default_sensitive: false
|
||||
default_federation: true
|
||||
hide_network: false
|
||||
unfollow_modal: false
|
||||
boost_modal: false
|
||||
|
Loading…
Reference in New Issue
Block a user