Privacy: add options to make interaction lists private and to not be included in public interaction lists.
parent
a47b1daaeb
commit
c983c4e952
|
@ -17,11 +17,12 @@ class Api::V1::Statuses::FavouritedByAccountsController < Api::BaseController
|
||||||
private
|
private
|
||||||
|
|
||||||
def load_accounts
|
def load_accounts
|
||||||
|
return [] if @status.local? && @status.account.user.setting_hide_interactions
|
||||||
default_accounts.merge(paginated_favourites).to_a
|
default_accounts.merge(paginated_favourites).to_a
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_accounts
|
def default_accounts
|
||||||
Account
|
Account.without_unlisted
|
||||||
.includes(:favourites, :account_stat)
|
.includes(:favourites, :account_stat)
|
||||||
.references(:favourites)
|
.references(:favourites)
|
||||||
.where(favourites: { status_id: @status.id })
|
.where(favourites: { status_id: @status.id })
|
||||||
|
|
|
@ -17,11 +17,12 @@ class Api::V1::Statuses::RebloggedByAccountsController < Api::BaseController
|
||||||
private
|
private
|
||||||
|
|
||||||
def load_accounts
|
def load_accounts
|
||||||
|
return [] if @status.local? && @status.account.user.setting_hide_interactions
|
||||||
default_accounts.merge(paginated_statuses).to_a
|
default_accounts.merge(paginated_statuses).to_a
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_accounts
|
def default_accounts
|
||||||
Account.includes(:statuses, :account_stat).references(:statuses)
|
Account.without_unlisted.includes(:statuses, :account_stat).references(:statuses)
|
||||||
end
|
end
|
||||||
|
|
||||||
def paginated_statuses
|
def paginated_statuses
|
||||||
|
|
|
@ -48,6 +48,7 @@ class Settings::PreferencesController < Settings::BaseController
|
||||||
:setting_gently_kobolds,
|
:setting_gently_kobolds,
|
||||||
:setting_user_is_kobold,
|
:setting_user_is_kobold,
|
||||||
:setting_hide_mascot,
|
:setting_hide_mascot,
|
||||||
|
:setting_hide_interactions,
|
||||||
|
|
||||||
:setting_default_privacy,
|
:setting_default_privacy,
|
||||||
:setting_default_sensitive,
|
:setting_default_sensitive,
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Settings::ProfilesController < Settings::BaseController
|
||||||
private
|
private
|
||||||
|
|
||||||
def account_params
|
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
|
end
|
||||||
|
|
||||||
def set_account
|
def set_account
|
||||||
|
|
|
@ -34,6 +34,7 @@ class UserSettingsDecorator
|
||||||
user.settings['user_is_kobold'] = user_is_kobold_preference if change?('setting_user_is_kobold')
|
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_captions'] = hide_captions_preference if change?('setting_hide_captions')
|
||||||
user.settings['hide_mascot'] = hide_mascot_preference if change?('setting_hide_mascot')
|
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['notification_emails'] = merged_notification_emails if change?('notification_emails')
|
||||||
user.settings['interactions'] = merged_interactions if change?('interactions')
|
user.settings['interactions'] = merged_interactions if change?('interactions')
|
||||||
|
@ -115,6 +116,10 @@ class UserSettingsDecorator
|
||||||
boolean_cast_setting 'setting_hide_mascot'
|
boolean_cast_setting 'setting_hide_mascot'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def hide_interactions_preference
|
||||||
|
boolean_cast_setting 'setting_hide_interactions'
|
||||||
|
end
|
||||||
|
|
||||||
def merged_notification_emails
|
def merged_notification_emails
|
||||||
user.settings['notification_emails'].merge coerced_settings('notification_emails').to_h
|
user.settings['notification_emails'].merge coerced_settings('notification_emails').to_h
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
# hidden :boolean default(FALSE), not null
|
# hidden :boolean default(FALSE), not null
|
||||||
# vars :jsonb not null
|
# vars :jsonb not null
|
||||||
# replies :boolean default(TRUE), not null
|
# replies :boolean default(TRUE), not null
|
||||||
|
# unlisted :boolean default(FALSE), not null
|
||||||
#
|
#
|
||||||
|
|
||||||
class Account < ApplicationRecord
|
class Account < ApplicationRecord
|
||||||
|
@ -108,6 +109,8 @@ class Account < ApplicationRecord
|
||||||
scope :tagged_with, ->(tag) { joins(:accounts_tags).where(accounts_tags: { tag_id: tag }) }
|
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 :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 :popular, -> { order('account_stats.followers_count desc') }
|
||||||
|
scope :without_hidden, -> { where(hidden: false) }
|
||||||
|
scope :without_unlisted, -> { where(unlisted: false) }
|
||||||
|
|
||||||
delegate :email,
|
delegate :email,
|
||||||
:unconfirmed_email,
|
:unconfirmed_email,
|
||||||
|
|
|
@ -122,6 +122,7 @@ class User < ApplicationRecord
|
||||||
:gently_kobolds,
|
:gently_kobolds,
|
||||||
:user_is_kobold,
|
:user_is_kobold,
|
||||||
:hide_mascot,
|
:hide_mascot,
|
||||||
|
:hide_interactions,
|
||||||
|
|
||||||
:auto_play_gif,
|
:auto_play_gif,
|
||||||
:default_sensitive,
|
:default_sensitive,
|
||||||
|
@ -280,6 +281,10 @@ class User < ApplicationRecord
|
||||||
settings.hide_mascot || false
|
settings.hide_mascot || false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def setting_hide_interactions
|
||||||
|
settings.hide_interactions || false
|
||||||
|
end
|
||||||
|
|
||||||
def setting_default_privacy
|
def setting_default_privacy
|
||||||
settings.default_privacy || 'public'
|
settings.default_privacy || 'public'
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
|
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :setting_hide_network, as: :boolean, wrapper: :with_label
|
= 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_hide_stats, as: :boolean, wrapper: :with_label
|
||||||
= f.input :setting_show_application, as: :boolean, wrapper: :with_label
|
= f.input :setting_show_application, as: :boolean, wrapper: :with_label
|
||||||
= f.input :setting_noindex, as: :boolean, wrapper: :with_label
|
= f.input :setting_noindex, as: :boolean, wrapper: :with_label
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :locked, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.locked')
|
= 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 :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
|
= f.input :replies, as: :boolean, wrapper: :with_label
|
||||||
|
|
||||||
.fields-group
|
.fields-group
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue