about summary refs log tree commit diff
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-07-21 20:50:30 -0500
committermultiple creatures <dev@multiple-creature.party>2019-07-21 20:50:30 -0500
commit084b9504017e519e33007f7aa8cdff7d571f954a (patch)
treebcefc968d1b5ae0ba40bac9adb2eb8955c3b6a21
parentbca5a3073f3f6bee2c64f3e199e9e56d0dd7ff7e (diff)
split `hide public profile` & `hide public ap outbox` into separate user options, make original `Account.hidden` prop federation-affecting `invisible mode`
-rw-r--r--app/controllers/accounts_controller.rb2
-rw-r--r--app/controllers/activitypub/outboxes_controller.rb2
-rw-r--r--app/controllers/settings/preferences_controller.rb1
-rw-r--r--app/lib/user_settings_decorator.rb5
-rw-r--r--app/models/account.rb1
-rw-r--r--app/models/user.rb5
-rw-r--r--app/views/settings/preferences/show.html.haml1
-rw-r--r--config/locales/simple_form.en.yml3
-rw-r--r--db/migrate/20190722014444_migrate_hidden_to_hide_profile.rb10
-rw-r--r--db/schema.rb4
10 files changed, 30 insertions, 4 deletions
diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb
index 4736b3596..22993934a 100644
--- a/app/controllers/accounts_controller.rb
+++ b/app/controllers/accounts_controller.rb
@@ -17,7 +17,7 @@ class AccountsController < ApplicationController
         @pinned_statuses   = []
         @endorsed_accounts = @account.endorsed_accounts.to_a.sample(4)
 
-        if current_account && @account.blocking?(current_account)
+        if @account.hidden || (@account&.user && @account.user.hides_public_profile?) || (current_account && @account.blocking?(current_account))
           @statuses = []
           return
         end
diff --git a/app/controllers/activitypub/outboxes_controller.rb b/app/controllers/activitypub/outboxes_controller.rb
index 3e617b10e..00d050dc3 100644
--- a/app/controllers/activitypub/outboxes_controller.rb
+++ b/app/controllers/activitypub/outboxes_controller.rb
@@ -55,7 +55,7 @@ class ActivityPub::OutboxesController < Api::BaseController
 
   def set_statuses
     return unless page_requested?
-    if @account&.user && @account.user.hides_public_outbox?
+    if @account.hidden || @account&.user && @account.user.hides_public_outbox?
       @statuses = Status.none
     else
       @statuses = @account.statuses.permitted_for(@account, signed_request_account)
diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb
index 031075fcd..b9f3a803d 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_profile,
       :setting_hide_public_outbox,
       :setting_max_public_history,
 
diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb
index a52bb7f56..4616142f8 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_profile'] = hide_public_profile_preference if change?('setting_hide_public_profile')
     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')
@@ -117,6 +118,10 @@ class UserSettingsDecorator
     boolean_cast_setting 'setting_hide_interactions'
   end
 
+  def hide_public_profile_preference
+    boolean_cast_setting 'setting_hide_public_profile'
+  end
+
   def hide_public_outbox_preference
     boolean_cast_setting 'setting_hide_public_outbox'
   end
diff --git a/app/models/account.rb b/app/models/account.rb
index 54d458666..1955b7aee 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_profile?,
            :hides_public_outbox?,
            :hides_interactions?,
            :hides_network?,
diff --git a/app/models/user.rb b/app/models/user.rb
index 24451741e..1d06a43f8 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_profile,
     :hide_public_outbox,
     :max_public_history,
 
@@ -286,6 +287,10 @@ class User < ApplicationRecord
     @hides_interactions ||= (settings.hide_interactions || false)
   end
 
+  def hides_public_profile?
+    @hides_public_profile ||= (settings.hide_public_profile || false)
+  end
+
   def hides_public_outbox?
     @hides_public_outbox ||= (settings.hide_public_outbox || false)
   end
diff --git a/app/views/settings/preferences/show.html.haml b/app/views/settings/preferences/show.html.haml
index 79bf40887..4a171ed9e 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_profile, as: :boolean, wrapper: :with_label
     = f.input :setting_hide_public_outbox, as: :boolean, wrapper: :with_label
 
   - unless Setting.hide_followers_count
diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml
index 7a201563a..4bebee68a 100644
--- a/config/locales/simple_form.en.yml
+++ b/config/locales/simple_form.en.yml
@@ -73,7 +73,7 @@ en:
           suspend: Suspend and irreversibly delete account data
         warning_preset_id: Use a warning preset
       defaults:
-        hidden: Disable your public profile
+        hidden: Invisible mode (affects outgoing federation and discovery!)
         adult_content: Contains adult content
         supports_chat: Allow chat messages
         gently: Gently the kobolds
@@ -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_profile: Hide your public profile from anonymous viewers
         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
diff --git a/db/migrate/20190722014444_migrate_hidden_to_hide_profile.rb b/db/migrate/20190722014444_migrate_hidden_to_hide_profile.rb
new file mode 100644
index 000000000..c4d305e6b
--- /dev/null
+++ b/db/migrate/20190722014444_migrate_hidden_to_hide_profile.rb
@@ -0,0 +1,10 @@
+class MigrateHiddenToHideProfile < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+  def up
+    Account.local.find_each do |account|
+      next unless account&.user
+      account.user.settings.hide_public_profile = account.hidden || false
+      account.hidden = false
+    end
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index fccde6264..2238213a4 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 2019_07_19_212820) do
+ActiveRecord::Schema.define(version: 2019_07_22_014444) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -667,6 +667,7 @@ ActiveRecord::Schema.define(version: 2019_07_19_212820) do
     t.boolean "edited"
     t.boolean "imported"
     t.string "origin"
+    t.tsvector "tsv"
     t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20180106", order: { id: :desc }
     t.index ["account_id", "id", "visibility"], name: "index_statuses_on_account_id_and_id_and_visibility", where: "(visibility = ANY (ARRAY[0, 1, 2, 4, 5]))"
     t.index ["in_reply_to_account_id"], name: "index_statuses_on_in_reply_to_account_id"
@@ -674,6 +675,7 @@ ActiveRecord::Schema.define(version: 2019_07_19_212820) do
     t.index ["network"], name: "index_statuses_on_network", where: "network"
     t.index ["origin"], name: "index_statuses_on_origin", unique: true
     t.index ["reblog_of_id", "account_id"], name: "index_statuses_on_reblog_of_id_and_account_id"
+    t.index ["tsv"], name: "tsv_idx", using: :gin
     t.index ["uri"], name: "index_statuses_on_uri", unique: true
   end