]> cat aescling's git repositories - mastodon.git/commitdiff
Record deleted(by mod) status to prevent re-appear (#10732)
authorJeong Arm <kjwonmail@gmail.com>
Thu, 9 May 2019 20:03:03 +0000 (05:03 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Thu, 9 May 2019 20:03:02 +0000 (22:03 +0200)
* Record deleted(by mod) status to prevent re-appear

* Move to Tombstone

* Add missing migration script

app/models/form/status_batch.rb
app/models/tombstone.rb
db/migrate/20190509164208_add_by_moderator_to_tombstone.rb [new file with mode: 0644]
db/schema.rb

index 89872806754ed9da47289f45dae468a970dce910..933dfdaca1ba5a7465093b921833b05f6da960f5 100644 (file)
@@ -35,6 +35,7 @@ class Form::StatusBatch
   def delete_statuses
     Status.where(id: status_ids).reorder(nil).find_each do |status|
       RemovalWorker.perform_async(status.id)
+      Tombstone.find_or_create_by(uri: status.uri, account: status.account, by_moderator: true)
       log_action :destroy, status
     end
 
index 997bb65fd068c4b0f33e8ba03e363e3338de1e4e..bf666c43ac19933c3c015baa2fd78a88352517a1 100644 (file)
@@ -4,11 +4,12 @@
 #
 # Table name: tombstones
 #
-#  id         :bigint(8)        not null, primary key
-#  account_id :bigint(8)
-#  uri        :string           not null
-#  created_at :datetime         not null
-#  updated_at :datetime         not null
+#  id           :bigint(8)        not null, primary key
+#  account_id   :bigint(8)
+#  uri          :string           not null
+#  created_at   :datetime         not null
+#  updated_at   :datetime         not null
+#  by_moderator :boolean
 #
 
 class Tombstone < ApplicationRecord
diff --git a/db/migrate/20190509164208_add_by_moderator_to_tombstone.rb b/db/migrate/20190509164208_add_by_moderator_to_tombstone.rb
new file mode 100644 (file)
index 0000000..80c2448
--- /dev/null
@@ -0,0 +1,5 @@
+class AddByModeratorToTombstone < ActiveRecord::Migration[5.2]
+  def change
+    add_column :tombstones, :by_moderator, :boolean
+  end
+end
index 8613539d644e80607168746f37668eab7bc61a0a..4dcbea4e75c141a8f406779ad8f37570166477cf 100644 (file)
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 2019_04_20_025523) do
+ActiveRecord::Schema.define(version: 2019_05_09_164208) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -382,9 +382,9 @@ ActiveRecord::Schema.define(version: 2019_04_20_025523) do
   create_table "mutes", force: :cascade do |t|
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
+    t.boolean "hide_notifications", default: true, null: false
     t.bigint "account_id", null: false
     t.bigint "target_account_id", null: false
-    t.boolean "hide_notifications", default: true, null: false
     t.index ["account_id", "target_account_id"], name: "index_mutes_on_account_id_and_target_account_id", unique: true
     t.index ["target_account_id"], name: "index_mutes_on_target_account_id"
   end
@@ -676,6 +676,7 @@ ActiveRecord::Schema.define(version: 2019_04_20_025523) do
     t.string "uri", null: false
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
+    t.boolean "by_moderator"
     t.index ["account_id"], name: "index_tombstones_on_account_id"
     t.index ["uri"], name: "index_tombstones_on_uri"
   end