Skip to content

Commit

Permalink
Record deleted(by mod) status to prevent re-appear (mastodon#10732)
Browse files Browse the repository at this point in the history
* Record deleted(by mod) status to prevent re-appear

* Move to Tombstone

* Add missing migration script
  • Loading branch information
tribela authored and hiyuki2578 committed Oct 2, 2019
1 parent 4172df6 commit c902859
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/models/form/status_batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def change_sensitive(sensitive)
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

Expand Down
11 changes: 6 additions & 5 deletions app/models/tombstone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20190509164208_add_by_moderator_to_tombstone.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddByModeratorToTombstone < ActiveRecord::Migration[5.2]
def change
add_column :tombstones, :by_moderator, :boolean
end
end
5 changes: 3 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -383,9 +383,9 @@
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
Expand Down Expand Up @@ -677,6 +677,7 @@
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
Expand Down

0 comments on commit c902859

Please sign in to comment.