diff options
author | multiple creatures <dev@multiple-creature.party> | 2019-07-21 20:21:20 -0500 |
---|---|---|
committer | multiple creatures <dev@multiple-creature.party> | 2019-07-21 20:21:20 -0500 |
commit | bca5a3073f3f6bee2c64f3e199e9e56d0dd7ff7e (patch) | |
tree | 748dc4ebe2704cedae2d54768927d8f43cd580a1 | |
parent | d9073f132b041fae818ae3894503065de123f257 (diff) |
privacy - add option to disable public activitypub outbox
-rw-r--r-- | app/controllers/activitypub/outboxes_controller.rb | 7 | ||||
-rw-r--r-- | app/controllers/settings/preferences_controller.rb | 1 | ||||
-rw-r--r-- | app/lib/user_settings_decorator.rb | 5 | ||||
-rw-r--r-- | app/models/account.rb | 1 | ||||
-rw-r--r-- | app/models/user.rb | 5 | ||||
-rw-r--r-- | app/views/settings/preferences/show.html.haml | 1 | ||||
-rw-r--r-- | config/locales/simple_form.en.yml | 1 |
7 files changed, 19 insertions, 2 deletions
diff --git a/app/controllers/activitypub/outboxes_controller.rb b/app/controllers/activitypub/outboxes_controller.rb index 438fa226e..3e617b10e 100644 --- a/app/controllers/activitypub/outboxes_controller.rb +++ b/app/controllers/activitypub/outboxes_controller.rb @@ -55,8 +55,11 @@ class ActivityPub::OutboxesController < Api::BaseController def set_statuses return unless page_requested? - - @statuses = @account.statuses.permitted_for(@account, signed_request_account) + if @account&.user && @account.user.hides_public_outbox? + @statuses = Status.none + else + @statuses = @account.statuses.permitted_for(@account, signed_request_account) + end @statuses = params[:min_id].present? ? @statuses.paginate_by_min_id(LIMIT, params[:min_id]).reverse : @statuses.paginate_by_max_id(LIMIT, params[:max_id]) @statuses = cache_collection(@statuses, Status) end diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb index 45bfd24b2..031075fcd 100644 --- a/app/controllers/settings/preferences_controller.rb +++ b/app/controllers/settings/preferences_controller.rb @@ -50,6 +50,7 @@ class Settings::PreferencesController < Settings::BaseController :setting_user_is_kobold, :setting_hide_mascot, :setting_hide_interactions, + :setting_hide_public_outbox, :setting_max_public_history, :setting_default_privacy, diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb index bf6a9fe2c..a52bb7f56 100644 --- a/app/lib/user_settings_decorator.rb +++ b/app/lib/user_settings_decorator.rb @@ -33,6 +33,7 @@ class UserSettingsDecorator 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['hide_public_outbox'] = hide_public_outbox_preference if change?('setting_hide_public_outbox') user.settings['larger_emoji'] = larger_emoji_preference if change?('setting_larger_emoji') user.settings['max_public_history'] = max_public_history_preference if change?('setting_max_public_history') @@ -116,6 +117,10 @@ class UserSettingsDecorator boolean_cast_setting 'setting_hide_interactions' end + def hide_public_outbox_preference + boolean_cast_setting 'setting_hide_public_outbox' + end + def max_public_history_preference settings['setting_max_public_history'] end diff --git a/app/models/account.rb b/app/models/account.rb index b3afdbcf7..54d458666 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -134,6 +134,7 @@ class Account < ApplicationRecord :always_local_only?, :max_public_history, + :hides_public_outbox?, :hides_interactions?, :hides_network?, :hides_stats?, diff --git a/app/models/user.rb b/app/models/user.rb index eeefce075..24451741e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -122,6 +122,7 @@ class User < ApplicationRecord :hide_mntions_packm8, :hide_mascot, :hide_interactions, + :hide_public_outbox, :max_public_history, :auto_play_gif, @@ -285,6 +286,10 @@ class User < ApplicationRecord @hides_interactions ||= (settings.hide_interactions || false) end + def hides_public_outbox? + @hides_public_outbox ||= (settings.hide_public_outbox || false) + end + def max_public_history @_max_public_history ||= (settings.max_public_history || 6) end diff --git a/app/views/settings/preferences/show.html.haml b/app/views/settings/preferences/show.html.haml index 5d5a277d2..79bf40887 100644 --- a/app/views/settings/preferences/show.html.haml +++ b/app/views/settings/preferences/show.html.haml @@ -45,6 +45,7 @@ .fields-group = f.input :setting_max_public_history, collection: [1, 3, 6, 7, 14, 30, 60, 90, 180, 365, 730, 1095, 2190], wrapper: :with_label, include_blank: false, label_method: lambda { |item| safe_join([t("simple_form.labels.defaults.setting_max_public_history_#{item}")]) }, selected: current_user.max_public_history.to_i + = f.input :setting_hide_public_outbox, as: :boolean, wrapper: :with_label - unless Setting.hide_followers_count .fields-group diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index dacbb5b37..7a201563a 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -153,6 +153,7 @@ en: setting_favourite_modal: Show confirmation dialog before admiring (in Glitch flavour) setting_hide_followers_count: Hide your packmates count setting_hide_network: Make your packmate lists private + setting_hide_public_outbox: Hide your public ActivityPub outbox (affects discoverability) setting_max_public_history: Limit history of roars on public profile to setting_max_public_history_1: 1 day setting_max_public_history_3: 3 days |