diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/api/v1/statuses/favourited_by_accounts_controller.rb | 3 | ||||
-rw-r--r-- | app/controllers/api/v1/statuses/reblogged_by_accounts_controller.rb | 3 | ||||
-rw-r--r-- | app/controllers/settings/preferences_controller.rb | 1 | ||||
-rw-r--r-- | app/controllers/settings/profiles_controller.rb | 2 | ||||
-rw-r--r-- | app/lib/user_settings_decorator.rb | 5 | ||||
-rw-r--r-- | app/models/account.rb | 3 | ||||
-rw-r--r-- | app/models/user.rb | 5 | ||||
-rw-r--r-- | app/views/settings/preferences/show.html.haml | 1 | ||||
-rw-r--r-- | app/views/settings/profiles/show.html.haml | 1 |
9 files changed, 21 insertions, 3 deletions
diff --git a/app/controllers/api/v1/statuses/favourited_by_accounts_controller.rb b/app/controllers/api/v1/statuses/favourited_by_accounts_controller.rb index 657e57831..d9d4bf7f3 100644 --- a/app/controllers/api/v1/statuses/favourited_by_accounts_controller.rb +++ b/app/controllers/api/v1/statuses/favourited_by_accounts_controller.rb @@ -17,11 +17,12 @@ class Api::V1::Statuses::FavouritedByAccountsController < Api::BaseController private def load_accounts + return [] if @status.local? && @status.account.user.setting_hide_interactions default_accounts.merge(paginated_favourites).to_a end def default_accounts - Account + Account.without_unlisted .includes(:favourites, :account_stat) .references(:favourites) .where(favourites: { status_id: @status.id }) diff --git a/app/controllers/api/v1/statuses/reblogged_by_accounts_controller.rb b/app/controllers/api/v1/statuses/reblogged_by_accounts_controller.rb index 6851099f6..15eb3a026 100644 --- a/app/controllers/api/v1/statuses/reblogged_by_accounts_controller.rb +++ b/app/controllers/api/v1/statuses/reblogged_by_accounts_controller.rb @@ -17,11 +17,12 @@ class Api::V1::Statuses::RebloggedByAccountsController < Api::BaseController private def load_accounts + return [] if @status.local? && @status.account.user.setting_hide_interactions default_accounts.merge(paginated_statuses).to_a end def default_accounts - Account.includes(:statuses, :account_stat).references(:statuses) + Account.without_unlisted.includes(:statuses, :account_stat).references(:statuses) end def paginated_statuses diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index afd6ee388..0a7b1326d 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -48,6 +48,7 @@ class Settings::PreferencesController < Settings::BaseController :setting_gently_kobolds, :setting_user_is_kobold, :setting_hide_mascot, + :setting_hide_interactions, :setting_default_privacy, :setting_default_sensitive, diff --git a/app/controllers/settings/profiles_controller.rb b/app/controllers/settings/profiles_controller.rb index 0ad5e6c3d..ac6635aea 100644 --- a/app/controllers/settings/profiles_controller.rb +++ b/app/controllers/settings/profiles_controller.rb @@ -25,7 +25,7 @@ class Settings::ProfilesController < Settings::BaseController private def account_params - params.require(:account).permit(:display_name, :note, :avatar, :header, :replies, :locked, :hidden, :bot, :discoverable, fields_attributes: [:name, :value]) + params.require(:account).permit(:display_name, :note, :avatar, :header, :replies, :locked, :hidden, :unlisted, :bot, :discoverable, fields_attributes: [:name, :value]) end def set_account diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb index 3dff63af4..69a8338d8 100644 --- a/app/lib/user_settings_decorator.rb +++ b/app/lib/user_settings_decorator.rb @@ -34,6 +34,7 @@ class UserSettingsDecorator user.settings['user_is_kobold'] = user_is_kobold_preference if change?('setting_user_is_kobold') user.settings['hide_captions'] = hide_captions_preference if change?('setting_hide_captions') user.settings['hide_mascot'] = hide_mascot_preference if change?('setting_hide_mascot') + user.settings['hide_interactions'] = hide_interactions_preference if change?('setting_hide_interactions') user.settings['notification_emails'] = merged_notification_emails if change?('notification_emails') user.settings['interactions'] = merged_interactions if change?('interactions') @@ -115,6 +116,10 @@ class UserSettingsDecorator boolean_cast_setting 'setting_hide_mascot' end + def hide_interactions_preference + boolean_cast_setting 'setting_hide_interactions' + end + def merged_notification_emails user.settings['notification_emails'].merge coerced_settings('notification_emails').to_h end diff --git a/app/models/account.rb b/app/models/account.rb index c07da2a14..dd644ea37 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -49,6 +49,7 @@ # hidden :boolean default(FALSE), not null # vars :jsonb not null # replies :boolean default(TRUE), not null +# unlisted :boolean default(FALSE), not null # class Account < ApplicationRecord @@ -108,6 +109,8 @@ class Account < ApplicationRecord scope :tagged_with, ->(tag) { joins(:accounts_tags).where(accounts_tags: { tag_id: tag }) } scope :by_recent_status, -> { order(Arel.sql('(case when account_stats.last_status_at is null then 1 else 0 end) asc, account_stats.last_status_at desc')) } scope :popular, -> { order('account_stats.followers_count desc') } + scope :without_hidden, -> { where(hidden: false) } + scope :without_unlisted, -> { where(unlisted: false) } delegate :email, :unconfirmed_email, diff --git a/app/models/user.rb b/app/models/user.rb index 95d2e6ffb..e5984b672 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -122,6 +122,7 @@ class User < ApplicationRecord :gently_kobolds, :user_is_kobold, :hide_mascot, + :hide_interactions, :auto_play_gif, :default_sensitive, @@ -280,6 +281,10 @@ class User < ApplicationRecord settings.hide_mascot || false end + def setting_hide_interactions + settings.hide_interactions || false + end + def setting_default_privacy settings.default_privacy || 'public' end diff --git a/app/views/settings/preferences/show.html.haml b/app/views/settings/preferences/show.html.haml index 0bc83130c..bfdcaf919 100644 --- a/app/views/settings/preferences/show.html.haml +++ b/app/views/settings/preferences/show.html.haml @@ -38,6 +38,7 @@ .fields-group = f.input :setting_hide_network, as: :boolean, wrapper: :with_label + = f.input :setting_hide_interactions, as: :boolean, wrapper: :with_label = f.input :setting_hide_stats, as: :boolean, wrapper: :with_label = f.input :setting_show_application, as: :boolean, wrapper: :with_label = f.input :setting_noindex, as: :boolean, wrapper: :with_label diff --git a/app/views/settings/profiles/show.html.haml b/app/views/settings/profiles/show.html.haml index 6e5145078..43d436cb1 100644 --- a/app/views/settings/profiles/show.html.haml +++ b/app/views/settings/profiles/show.html.haml @@ -23,6 +23,7 @@ .fields-group = f.input :locked, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.locked') = f.input :hidden, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.hidden') + = f.input :unlisted, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.unlisted') = f.input :replies, as: :boolean, wrapper: :with_label .fields-group |