Privacy: add options to make interaction lists private and to not be included in public interaction lists.

staging
multiple creatures 2019-05-05 23:08:13 -05:00
parent a47b1daaeb
commit c983c4e952
10 changed files with 26 additions and 3 deletions

View File

@ -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 })

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,5 @@
class AddUnlistedToAccounts < ActiveRecord::Migration[5.2]
def change
safety_assured { add_column :accounts, :unlisted, :boolean, null: false, default: false }
end
end