From d9c8abca54326c13810e87352e33a85fa6ca04db Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Sun, 26 Jul 2020 06:37:23 -0500 Subject: [Privacy] Exclude mixed-privacy posts from public collections unless the requesting actor is locally authenticated or follows the author --- db/migrate/20200726094737_add_semiprivate_to_statuses.rb | 7 +++++++ .../20200726095058_backfill_semiprivate_on_statuses.rb | 14 ++++++++++++++ db/schema.rb | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20200726094737_add_semiprivate_to_statuses.rb create mode 100644 db/migrate/20200726095058_backfill_semiprivate_on_statuses.rb (limited to 'db') diff --git a/db/migrate/20200726094737_add_semiprivate_to_statuses.rb b/db/migrate/20200726094737_add_semiprivate_to_statuses.rb new file mode 100644 index 000000000..facde265c --- /dev/null +++ b/db/migrate/20200726094737_add_semiprivate_to_statuses.rb @@ -0,0 +1,7 @@ +class AddSemiprivateToStatuses < ActiveRecord::Migration[5.2] + def change + safety_assured do + add_column :statuses, :semiprivate, :boolean, default: false, null: false + end + end +end diff --git a/db/migrate/20200726095058_backfill_semiprivate_on_statuses.rb b/db/migrate/20200726095058_backfill_semiprivate_on_statuses.rb new file mode 100644 index 000000000..69878ab94 --- /dev/null +++ b/db/migrate/20200726095058_backfill_semiprivate_on_statuses.rb @@ -0,0 +1,14 @@ +class BackfillSemiprivateOnStatuses < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def up + Rails.logger.info('Backfilling semiprivate statuses...') + safety_assured do + Status.where(id: StatusDomainPermission.select(:status_id).distinct(:status_id)).in_batches.update_all(semiprivate: true) + end + end + + def down + true + end +end diff --git a/db/schema.rb b/db/schema.rb index 0f649b382..a9f0b0653 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: 2020_07_25_080000) do +ActiveRecord::Schema.define(version: 2020_07_26_095058) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -834,6 +834,7 @@ ActiveRecord::Schema.define(version: 2020_07_25_080000) do t.integer "nest_level", limit: 2, default: 0, null: false t.boolean "published", default: true, null: false t.text "title" + t.boolean "semiprivate", default: false, null: false t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20190820", order: { id: :desc }, where: "(deleted_at IS NULL)" t.index ["account_id", "id"], name: "index_unpublished_statuses", order: { id: :desc }, where: "((deleted_at IS NULL) AND (published = false))" t.index ["conversation_id"], name: "index_statuses_on_conversation_id", where: "(deleted_at IS NULL)" -- cgit