diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20200721184347_limit_visibility_of_replies_to_private_statuses.rb | 13 | ||||
-rw-r--r-- | db/schema.rb | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/db/migrate/20200721184347_limit_visibility_of_replies_to_private_statuses.rb b/db/migrate/20200721184347_limit_visibility_of_replies_to_private_statuses.rb new file mode 100644 index 000000000..d22242bdd --- /dev/null +++ b/db/migrate/20200721184347_limit_visibility_of_replies_to_private_statuses.rb @@ -0,0 +1,13 @@ +class LimitVisibilityOfRepliesToPrivateStatuses < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def up + Status.includes(:thread).where.not(visibility: :direct).where(reply: true).where('statuses.in_reply_to_account_id != statuses.account_id').find_each do |status| + status.update!(visibility: status.thread.visibility) unless status.thread.nil? || %w(public unlisted).include?(status.thread.visibility) || ['direct', 'limited', status.thread.visibility].include?(status.visibility) + end + end + + def down + true + end +end diff --git a/db/schema.rb b/db/schema.rb index b1fcad7db..aa0790fc6 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_20_212317) do +ActiveRecord::Schema.define(version: 2020_07_21_184347) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" |