diff options
-rw-r--r-- | app/helpers/stream_entries_helper.rb | 6 | ||||
-rw-r--r-- | app/lib/status_filter.rb | 22 | ||||
-rw-r--r-- | app/models/account.rb | 41 | ||||
-rw-r--r-- | app/models/user.rb | 96 | ||||
-rw-r--r-- | app/serializers/initial_state_serializer.rb | 8 | ||||
-rw-r--r-- | app/services/post_status_service.rb | 8 | ||||
-rwxr-xr-x | app/views/layouts/application.html.haml | 14 | ||||
-rw-r--r-- | app/views/stream_entries/_detailed_status.html.haml | 4 |
8 files changed, 113 insertions, 86 deletions
diff --git a/app/helpers/stream_entries_helper.rb b/app/helpers/stream_entries_helper.rb index 8757518b4..ee26fd022 100644 --- a/app/helpers/stream_entries_helper.rb +++ b/app/helpers/stream_entries_helper.rb @@ -39,8 +39,8 @@ module StreamEntriesHelper roles = [] roles << content_tag(:div, t('accounts.roles.bot'), class: 'account-role bot') if account.bot? roles << content_tag(:div, t('accounts.roles.adults_only'), class: 'account-role adults-only') if account.adults_only? - roles << content_tag(:div, t('accounts.roles.gentlies_kobolds'), class: 'account-role gentlies') if account&.user&.setting_gently_kobolds - roles << content_tag(:div, t('accounts.roles.kobold'), class: 'account-role kobold') if account&.user&.setting_user_is_kobold + roles << content_tag(:div, t('accounts.roles.gentlies_kobolds'), class: 'account-role gentlies') if account.user_gentlies_kobolds? + roles << content_tag(:div, t('accounts.roles.kobold'), class: 'account-role kobold') if account.user_is_kobold? if (Setting.show_staff_badge && account.user_staff?) || all if all && !account.user_staff? @@ -71,7 +71,7 @@ module StreamEntriesHelper end def hide_stats?(account) - Setting.hide_stats || account.user&.setting_hide_stats + Setting.hide_stats || account.user_hides_stats? end def account_description(account) diff --git a/app/lib/status_filter.rb b/app/lib/status_filter.rb index 23c2fb236..0c5e9e435 100644 --- a/app/lib/status_filter.rb +++ b/app/lib/status_filter.rb @@ -28,9 +28,9 @@ class StatusFilter def filtered_reference? # filter muted/blocked - return true if account.user_hide_replies_of_blocked? && reply_to_blocked? - return true if account.user_hide_replies_of_muted? && reply_to_muted? - return true if account.user_hide_replies_of_blocker? && reply_to_blocker? + return true if account.user_hides_replies_of_blocked? && reply_to_blocked? + return true if account.user_hides_replies_of_muted? && reply_to_muted? + return true if account.user_hides_replies_of_blocker? && reply_to_blocker? # kajiht has no filters if status has no mentions return false if status&.mentions.blank? @@ -42,22 +42,22 @@ class StatusFilter return false if mentioned_account_ids.include?(account.id) return true if mentioned_account_ids.any? do |mentioned_account_id| - return true if @preloaded_relations[:muting] && account.user_hide_mentions_of_muted? && @preloaded_relations[:muting][mentioned_account_id] - return true if @preloaded_relations[:blocking] && account.user_hide_mentions_of_blocked? && @preloaded_relations[:blocking][mentioned_account_id] + return true if @preloaded_relations[:muting] && account.user_hides_mentions_of_muted? && @preloaded_relations[:muting][mentioned_account_id] + return true if @preloaded_relations[:blocking] && account.user_hides_mentions_of_blocked? && @preloaded_relations[:blocking][mentioned_account_id] if @preloaded_relations[:blocked_by] - return true if account.user_hide_mentions_of_blocker? && @preloaded_relations[:blocked_by][mentioned_account_id] + return true if account.user_hides_mentions_of_blocker? && @preloaded_relations[:blocked_by][mentioned_account_id] else - return true if account.user_hide_mentions_of_blocker? && Account.find(mentioned_account_id)&.blocking?(account.id) + return true if account.user_hides_mentions_of_blocker? && Account.find(mentioned_account_id)&.blocking?(account.id) end return false unless status.private_visibility? && status.reply? - @preloaded_relations[:following] && account.user_hide_mentions_outside_scope? && !@preloaded_relations[:following][mentioned_account_id] + @preloaded_relations[:following] && account.user_hides_mentions_outside_scope? && !@preloaded_relations[:following][mentioned_account_id] end - return true if !@preloaded_relations[:following] && account.user_hide_mentions_outside_scope? && status.private_visibility? && status.reply? && (mentioned_account_ids - account.following_ids).any? - return true if !@preloaded_relations[:muting] && account.user_hide_mentions_of_muted? && account.muting?(mentioned_account_ids) - return true if !@preloaded_relations[:blocking] && account.user_hide_mentions_of_blocked? && account.blocking?(mentioned_account_ids) + return true if !@preloaded_relations[:following] && account.user_hides_mentions_outside_scope? && status.private_visibility? && status.reply? && (mentioned_account_ids - account.following_ids).any? + return true if !@preloaded_relations[:muting] && account.user_hides_mentions_of_muted? && account.muting?(mentioned_account_ids) + return true if !@preloaded_relations[:blocking] && account.user_hides_mentions_of_blocked? && account.blocking?(mentioned_account_ids) end def reply_to_blocked? diff --git a/app/models/account.rb b/app/models/account.rb index 5f88a951f..704e5bcc7 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -123,19 +123,38 @@ class Account < ApplicationRecord :moderator?, :staff?, :locale, - :default_sensitive?, + + :default_language, + :default_visibility, + + :defaults_to_sensitive?, + :defaults_to_local_only?, + :always_local_only?, + + :hides_interactions?, :hides_network?, + :hides_stats?, :shows_application?, - :always_local?, - :default_local?, - :no_blabber_blocks?, - :hide_replies_of_muted?, - :hide_replies_of_blocked?, - :hide_replies_of_blocker?, - :hide_mntions_of_muted?, - :hide_mntions_of_blocked?, - :hide_mntions_of_blocker?, - :hide_mntions_of_outside_scope?, + + :gentlies_kobolds?, + :is_a_kobold?, + + :hides_replies_of_muted?, + :hides_replies_of_blocked?, + :hides_replies_of_blocker?, + :hides_mentions_of_muted?, + :hides_mentions_of_blocked?, + :hides_mentions_of_blocker?, + :hides_mentions_outside_scope?, + + :wants_larger_menus?, + :wants_larger_buttons?, + :wants_larger_drawer?, + :hides_filtered_gap?, + :hides_mascot?, + :hides_color_formatting?, + :hides_captions, + to: :user, prefix: true, allow_nil: true diff --git a/app/models/user.rb b/app/models/user.rb index 2bd039958..343d68db5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -225,92 +225,100 @@ class User < ApplicationRecord save! end - def larger_menus? - @larger_menus ||= (settings.larger_menus || false) + def wants_larger_menus? + @wants_larger_menus ||= (settings.larger_menus || false) end - def larger_buttons? - @larger_buttons ||= (settings.larger_buttons || false) + def wants_larger_buttons? + @wants_larger_buttons ||= (settings.larger_buttons || false) end - def larger_drawer? - @larger_drawer ||= (settings.larger_drawer || false) + def wants_larger_drawer? + @wants_larger_drawer ||= (settings.larger_drawer || false) end - def remove_filtered? - @remove_filtered ||= (settings.remove_filtered || false) + def hides_filtered_gap? + @hides_filtered_gap ||= (settings.remove_filtered || false) end - def hide_replies_muted? - @hide_replies ||= (settings.hide_replies_muted || true) + def hides_replies_of_muted? + @hides_replies_of_muted ||= (settings.hide_replies_muted || true) end - def hide_replies_of_blocked? - @hide_replies_of_blocked ||= (settings.hide_replies_blocked || true) + def hides_replies_of_blocked? + @hides_replies_of_blocked ||= (settings.hide_replies_blocked || true) end - def hide_replies_of_blocker? - @hide_replies_of_blocker ||= (settings.hide_replies_blocker || true) + def hides_replies_of_blocker? + @hides_replies_of_blocker ||= (settings.hide_replies_blocker || true) end - def hide_mentions_of_muted? - @hide_mentions_of_muted ||= (settings.hide_mntions_muted || true) + def hides_mentions_of_muted? + @hides_mentions_of_muted ||= (settings.hide_mntions_muted || true) end - def hide_mentions_of_blocked? - @hide_mentions_of_blocked ||= (settings.hide_mntions_blocked || true) + def hides_mentions_of_blocked? + @hides_mentions_of_blocked ||= (settings.hide_mntions_blocked || true) end - def hide_mentions_of_blocker? - @hide_mentions_of_blocker ||= (settings.hide_mntions_blocker || true) + def hides_mentions_of_blocker? + @hides_mentions_of_blocker ||= (settings.hide_mntions_blocker || true) end - def hide_mentions_outside_scope? - @hide_mentions_outside_scope ||= (settings.hide_mntions_packm8 || true) + def hides_mentions_outside_scope? + @hides_mentions_outside_scope ||= (settings.hide_mntions_packm8 || true) end - def gently_kobolds? - @gently_kobolds ||= (settings.gently_kobolds || false) + def gentlies_kobolds? + @gentlies_kobolds ||= (settings.gently_kobolds || false) end - def user_is_kobold? - @user_is_kobold ||= (settings.user_is_kobold || false) + def is_a_kobold? + @is_a_kobold ||= (settings.user_is_kobold || false) end - def hide_mascot? - @hide_mascop ||= (settings.hide_mascot || false) + def hides_mascot? + @hides_mascot ||= (settings.hide_mascot || false) end - def hide_interactions? - @hide_interactions ||= (settings.hide_interactions || false) + def hides_interactions? + @hides_interactions ||= (settings.hide_interactions || false) end - def default_local? - @default_local ||= (settings.default_local || false) + def defaults_to_local_only? + @defaults_to_local_only ||= (settings.default_local || false) end - def always_local? - @always_local ||= (settings.always_local || false) + def always_local_only? + @always_local_only ||= (settings.always_local || false) end - def rawr_federated? - @rawr_federated ||= (settings.rawr_federated || false) + def wants_raw_federated? + @wants_raw_federated ||= (settings.rawr_federated || false) end - def disable_color? - @disable_color ||= (settings.disable_color || false) + def hides_color_formatting? + @hides_color_formatting ||= (settings.disable_color || false) end - def hide_stats? - @hide_stats ||= (settings.hide_stats || false) + def hides_stats? + @hides_stats ||= (settings.hide_stats || false) end - def hide_captions? - @hide_captions ||= (settings.hide_captions || false) + def hides_captions? + @hides_captions ||= (settings.hide_captions || false) end - def default_sensitive? - @default_sensitive ||= settings.default_sensitive + def defaults_to_sensitive? + @defaults_to_sensitive ||= settings.default_sensitive + end + + def default_visibility + @default_visibility ||= setting_default_privacy + end + + def default_language + @_default_language ||= (setting.default_language || 'en') end def setting_default_privacy diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index 4622ddb9e..7afeffe25 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -38,8 +38,8 @@ 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[:always_local] = object.current_account.user.setting_always_local + store[:default_local] = object.current_account.user_defaults_to_local_only? + store[:always_local] = object.current_account.user_always_local_only? 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 @@ -60,8 +60,8 @@ class InitialStateSerializer < ActiveModel::Serializer if object.current_account 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_privacy] = object.current_account.user_default_visibility + store[:default_sensitive] = object.current_account.user_defaults_to_sensitive? end store[:text] = object.text if object.text diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index 5a73b541f..0030fc603 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -58,7 +58,7 @@ class PostStatusService < BaseService @text = @media.find(&:video?) ? '📹' : '🖼' if @media.size > 0 end - @visibility = @options[:visibility] || @account.user&.setting_default_privacy + @visibility = @options[:visibility] || @account.user_default_visibility @visibility = :unlisted if @visibility.in?([nil, 'public']) && @account.silenced? || @account.force_unlisted if @in_reply_to.present? && @in_reply_to.visibility.present? @@ -66,9 +66,9 @@ class PostStatusService < BaseService @visibility = @in_reply_to.visibility if @visibility.nil? || v.index(@visibility) < v.index(@in_reply_to.visibility) end - @local_only = true if @account.user_always_local? || @in_reply_to&.local_only + @local_only = true if @account.user_always_local_only? || @in_reply_to&.local_only - @sensitive = (@account.default_sensitive? || @options[:spoiler_text].present?) if @sensitive.nil? + @sensitive = (@account.user_defaults_to_sensitive? || @options[:spoiler_text].present?) if @sensitive.nil? @scheduled_at = @options[:scheduled_at]&.to_datetime @scheduled_at = nil if scheduled_in_the_past? @@ -184,7 +184,7 @@ class PostStatusService < BaseService visibility: @visibility, local_only: @local_only, sharekey: @sharekey, - language: language_from_option(@options[:language]) || @account.user&.setting_default_language&.presence || 'en', + language: language_from_option(@options[:language]) || @account.default_language&.presence || 'en', application: @options[:application], content_type: @options[:content_type] || @account.user&.setting_default_content_type, }.compact diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 6bd9a00ab..f01329914 100755 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -37,7 +37,7 @@ - if Setting.custom_css.present? = stylesheet_link_tag custom_css_path, media: 'all' - - if current_account&.user&.setting_disable_color + - if current_account.user_hides_color_formatting? :css .status__content p > span, .reply-indicator__content p > span, @@ -46,20 +46,20 @@ .account__header__fields p > span { color: inherit !important } - - if current_account&.user&.setting_hide_captions + - if current_account.user_hides_captions? :css div .media-caption, span .caption { display: none } - - if current_account&.user&.setting_larger_menus + - if current_account.user_wants_larger_menus? :css .dropdown-menu__item a { padding: 14px 14px !important; font-size: 14px !important } .dropdown--active .dropdown__content > ul > li > a { padding: 14px 0 !important; font-size: 14px !important } - - if current_account&.user&.setting_larger_buttons + - if current_account.user_wants_larger_buttons? :css .drawer { min-width: 350px !important } .status__action-bar .icon-button, @@ -73,15 +73,15 @@ margin-right: 24px; } - - if current_account&.user&.setting_larger_drawer + - if current_account.user_wants_larger_drawer? :css .drawer { min-width: 400px !important } - - if current_account&.user&.setting_remove_filtered + - if current_account.user_hides_filtered_gap? :css .status__wrapper--filtered { display: none !important; } - - if current_account&.user&.setting_hide_mascot + - if current_account.user_hides_mascot? :css .drawer__inner__mastodon>img { display: none !important } diff --git a/app/views/stream_entries/_detailed_status.html.haml b/app/views/stream_entries/_detailed_status.html.haml index 372d29b7c..b7015e356 100644 --- a/app/views/stream_entries/_detailed_status.html.haml +++ b/app/views/stream_entries/_detailed_status.html.haml @@ -65,13 +65,13 @@ · %span.detailed-status__link< = fa_icon('lock') - - elsif user_signed_in? && !@account.user&.setting_hide_stats + - elsif user_signed_in? && !@account.user_hides_stats? · = link_to remote_interaction_path(status, type: :reblog), class: 'modal-button detailed-status__link', title: number_to_human(status.reblogs_count, strip_insignificant_zeros: true) do = fa_icon('repeat') = " " - - if user_signed_in? && !@account.user&.setting_hide_stats + - if user_signed_in? && !@account.user_hides_stats? · = link_to remote_interaction_path(status, type: :favourite), class: 'modal-button detailed-status__link', title: number_to_human(status.favourites_count, strip_insignificant_zeros: true) do = fa_icon('star') |