mirror of
https://github.com/mastodon/mastodon.git
synced 2025-10-05 16:42:47 +00:00
Change “Posting defaults” settings page to enforce nobody
quote policy for private
default visibility (#36040)
This commit is contained in:
parent
7ddb8814e1
commit
9463a31107
|
@ -6,4 +6,10 @@ class Settings::Preferences::PostingDefaultsController < Settings::Preferences::
|
||||||
def after_update_redirect_path
|
def after_update_redirect_path
|
||||||
settings_preferences_posting_defaults_path
|
settings_preferences_posting_defaults_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def user_params
|
||||||
|
super.tap do |params|
|
||||||
|
params[:settings_attributes][:default_quote_policy] = 'nobody' if params[:settings_attributes][:default_privacy] == 'private'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -145,6 +145,10 @@ function loaded() {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
updateDefaultQuotePrivacyFromPrivacy(
|
||||||
|
document.querySelector('#user_settings_attributes_default_privacy'),
|
||||||
|
);
|
||||||
|
|
||||||
const reactComponents = document.querySelectorAll('[data-component]');
|
const reactComponents = document.querySelectorAll('[data-component]');
|
||||||
|
|
||||||
if (reactComponents.length > 0) {
|
if (reactComponents.length > 0) {
|
||||||
|
@ -364,6 +368,34 @@ Rails.delegate(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const updateDefaultQuotePrivacyFromPrivacy = (
|
||||||
|
privacySelect: EventTarget | null,
|
||||||
|
) => {
|
||||||
|
if (!(privacySelect instanceof HTMLSelectElement) || !privacySelect.form)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const select = privacySelect.form.querySelector<HTMLSelectElement>(
|
||||||
|
'select#user_settings_attributes_default_quote_policy',
|
||||||
|
);
|
||||||
|
if (!select) return;
|
||||||
|
|
||||||
|
if (privacySelect.value === 'private') {
|
||||||
|
select.value = 'nobody';
|
||||||
|
setInputDisabled(select, true);
|
||||||
|
} else {
|
||||||
|
setInputDisabled(select, false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Rails.delegate(
|
||||||
|
document,
|
||||||
|
'#user_settings_attributes_default_privacy',
|
||||||
|
'change',
|
||||||
|
({ target }) => {
|
||||||
|
updateDefaultQuotePrivacyFromPrivacy(target);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
// Empty the honeypot fields in JS in case something like an extension
|
// Empty the honeypot fields in JS in case something like an extension
|
||||||
// automatically filled them.
|
// automatically filled them.
|
||||||
Rails.delegate(document, '#registration_new_user,#new_user', 'submit', () => {
|
Rails.delegate(document, '#registration_new_user,#new_user', 'submit', () => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user