Add setting a always mark media as sensitive (#4136)
This commit is contained in:
parent
617208053c
commit
2b9721d1b3
|
@ -34,6 +34,7 @@ class Settings::PreferencesController < ApplicationController
|
|||
def user_settings_params
|
||||
params.require(:user).permit(
|
||||
:setting_default_privacy,
|
||||
:setting_default_sensitive,
|
||||
:setting_boost_modal,
|
||||
:setting_delete_modal,
|
||||
:setting_auto_play_gif,
|
||||
|
|
|
@ -45,6 +45,7 @@ const initialState = Immutable.Map({
|
|||
suggestions: Immutable.List(),
|
||||
me: null,
|
||||
default_privacy: 'public',
|
||||
default_sensitive: false,
|
||||
resetFileKey: Math.floor((Math.random() * 0x10000)),
|
||||
idempotencyKey: null,
|
||||
});
|
||||
|
@ -75,6 +76,8 @@ function clearAll(state) {
|
|||
};
|
||||
|
||||
function appendMedia(state, media) {
|
||||
const prevSize = state.get('media_attachments').size;
|
||||
|
||||
return state.withMutations(map => {
|
||||
map.update('media_attachments', list => list.push(media));
|
||||
map.set('is_uploading', false);
|
||||
|
@ -82,6 +85,10 @@ function appendMedia(state, media) {
|
|||
map.update('text', oldText => `${oldText.trim()} ${media.get('text_url')}`);
|
||||
map.set('focusDate', new Date());
|
||||
map.set('idempotencyKey', uuid());
|
||||
|
||||
if (prevSize === 0 && state.get('default_sensitive')) {
|
||||
map.set('sensitive', true);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ class UserSettingsDecorator
|
|||
user.settings['notification_emails'] = merged_notification_emails
|
||||
user.settings['interactions'] = merged_interactions
|
||||
user.settings['default_privacy'] = default_privacy_preference
|
||||
user.settings['default_sensitive'] = default_sensitive_preference
|
||||
user.settings['boost_modal'] = boost_modal_preference
|
||||
user.settings['delete_modal'] = delete_modal_preference
|
||||
user.settings['auto_play_gif'] = auto_play_gif_preference
|
||||
|
@ -36,6 +37,10 @@ class UserSettingsDecorator
|
|||
settings['setting_default_privacy']
|
||||
end
|
||||
|
||||
def default_sensitive_preference
|
||||
boolean_cast_setting 'setting_default_sensitive'
|
||||
end
|
||||
|
||||
def boost_modal_preference
|
||||
boolean_cast_setting 'setting_boost_modal'
|
||||
end
|
||||
|
|
|
@ -79,6 +79,10 @@ class User < ApplicationRecord
|
|||
settings.default_privacy || (account.locked? ? 'private' : 'public')
|
||||
end
|
||||
|
||||
def setting_default_sensitive
|
||||
settings.default_sensitive
|
||||
end
|
||||
|
||||
def setting_boost_modal
|
||||
settings.boost_modal
|
||||
end
|
||||
|
|
|
@ -23,6 +23,7 @@ class InitialStateSerializer < ActiveModel::Serializer
|
|||
{
|
||||
me: object.current_account.id,
|
||||
default_privacy: object.current_account.user.setting_default_privacy,
|
||||
default_sensitive: object.current_account.user.setting_default_sensitive,
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ class REST::CredentialAccountSerializer < REST::AccountSerializer
|
|||
user = object.user
|
||||
{
|
||||
privacy: user.setting_default_privacy,
|
||||
sensitive: user.setting_default_sensitive,
|
||||
note: object.note,
|
||||
}
|
||||
end
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
= f.input :setting_default_privacy, collection: Status.visibilities.keys - ['direct'], wrapper: :with_label, include_blank: false, label_method: lambda { |visibility| safe_join([I18n.t("statuses.visibilities.#{visibility}"), content_tag(:span, I18n.t("statuses.visibilities.#{visibility}_long"), class: 'hint')]) }, required: false, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li'
|
||||
|
||||
= f.input :setting_default_sensitive, as: :boolean, wrapper: :with_label
|
||||
|
||||
.fields-group
|
||||
= f.simple_fields_for :notification_emails, hash_to_object(current_user.settings.notification_emails) do |ff|
|
||||
= ff.input :follow, as: :boolean, wrapper: :with_label
|
||||
|
|
|
@ -37,6 +37,7 @@ en:
|
|||
setting_auto_play_gif: Auto-play animated GIFs
|
||||
setting_boost_modal: Show confirmation dialog before boosting
|
||||
setting_default_privacy: Post privacy
|
||||
setting_default_sensitive: Always mark media as sensitive
|
||||
setting_delete_modal: Show confirmation dialog before deleting a toot
|
||||
setting_system_font_ui: Use system's default font
|
||||
severity: Severity
|
||||
|
|
|
@ -28,6 +28,13 @@ describe UserSettingsDecorator do
|
|||
expect(user.settings['default_privacy']).to eq 'public'
|
||||
end
|
||||
|
||||
it 'updates the user settings value for sensitive' do
|
||||
values = { 'setting_default_sensitive' => '1' }
|
||||
|
||||
settings.update(values)
|
||||
expect(user.settings['default_sensitive']).to eq true
|
||||
end
|
||||
|
||||
it 'updates the user settings value for boost modal' do
|
||||
values = { 'setting_boost_modal' => '1' }
|
||||
|
||||
|
|
Loading…
Reference in New Issue