Skip to content

Commit c902859

Browse files
tribelahiyuki2578
authored andcommitted
Record deleted(by mod) status to prevent re-appear (mastodon#10732)
* Record deleted(by mod) status to prevent re-appear * Move to Tombstone * Add missing migration script
1 parent 4172df6 commit c902859

4 files changed

Lines changed: 15 additions & 7 deletions

File tree

app/models/form/status_batch.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def change_sensitive(sensitive)
3535
def delete_statuses
3636
Status.where(id: status_ids).reorder(nil).find_each do |status|
3737
RemovalWorker.perform_async(status.id)
38+
Tombstone.find_or_create_by(uri: status.uri, account: status.account, by_moderator: true)
3839
log_action :destroy, status
3940
end
4041

app/models/tombstone.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
#
55
# Table name: tombstones
66
#
7-
# id :bigint(8) not null, primary key
8-
# account_id :bigint(8)
9-
# uri :string not null
10-
# created_at :datetime not null
11-
# updated_at :datetime not null
7+
# id :bigint(8) not null, primary key
8+
# account_id :bigint(8)
9+
# uri :string not null
10+
# created_at :datetime not null
11+
# updated_at :datetime not null
12+
# by_moderator :boolean
1213
#
1314

1415
class Tombstone < ApplicationRecord
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddByModeratorToTombstone < ActiveRecord::Migration[5.2]
2+
def change
3+
add_column :tombstones, :by_moderator, :boolean
4+
end
5+
end

db/schema.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2019_04_20_025523) do
13+
ActiveRecord::Schema.define(version: 2019_05_09_164208) do
1414

1515
# These are extensions that must be enabled in order to support this database
1616
enable_extension "plpgsql"
@@ -383,9 +383,9 @@
383383
create_table "mutes", force: :cascade do |t|
384384
t.datetime "created_at", null: false
385385
t.datetime "updated_at", null: false
386+
t.boolean "hide_notifications", default: true, null: false
386387
t.bigint "account_id", null: false
387388
t.bigint "target_account_id", null: false
388-
t.boolean "hide_notifications", default: true, null: false
389389
t.index ["account_id", "target_account_id"], name: "index_mutes_on_account_id_and_target_account_id", unique: true
390390
t.index ["target_account_id"], name: "index_mutes_on_target_account_id"
391391
end
@@ -677,6 +677,7 @@
677677
t.string "uri", null: false
678678
t.datetime "created_at", null: false
679679
t.datetime "updated_at", null: false
680+
t.boolean "by_moderator"
680681
t.index ["account_id"], name: "index_tombstones_on_account_id"
681682
t.index ["uri"], name: "index_tombstones_on_uri"
682683
end

0 commit comments

Comments
 (0)