diff options
author | Fire Demon <firedemon@creature.cafe> | 2020-07-21 14:52:34 -0500 |
---|---|---|
committer | Fire Demon <firedemon@creature.cafe> | 2020-08-30 05:44:01 -0500 |
commit | bbe174b422b3c72eda966fd6c31a6484fffdf753 (patch) | |
tree | e67ed6467e197099cb1f789b9d990c4a57773184 /db | |
parent | 750c48980b83689cdce849f058f661078c6dd228 (diff) |
[Privacy, Database] Limit visibility of replies to private posts
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" |