about summary refs log tree commit diff
path: root/db/migrate
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-07-21 14:52:34 -0500
committerFire Demon <firedemon@creature.cafe>2020-08-30 05:44:01 -0500
commitbbe174b422b3c72eda966fd6c31a6484fffdf753 (patch)
treee67ed6467e197099cb1f789b9d990c4a57773184 /db/migrate
parent750c48980b83689cdce849f058f661078c6dd228 (diff)
[Privacy, Database] Limit visibility of replies to private posts
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20200721184347_limit_visibility_of_replies_to_private_statuses.rb13
1 files changed, 13 insertions, 0 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