From 3c033c4352f8b156887cd7157b4a89c23a545838 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 22 Dec 2018 20:02:09 +0100 Subject: Add moderation warnings (#9519) * Add moderation warnings Replace individual routes for disabling, silencing, and suspending a user, as well as the report update route, with a unified account action controller that allows you to select an action (none, disable, silence, suspend) as well as whether it should generate an e-mail notification with optional custom text. That notification, with the optional custom text, is saved as a warning. Additionally, there are warning presets you can configure to save time when performing the above. * Use Account#local_username_and_domain --- .../20181213184704_create_account_warnings.rb | 12 ++++++++++++ ...20181213185533_create_account_warning_presets.rb | 9 +++++++++ db/schema.rb | 21 ++++++++++++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20181213184704_create_account_warnings.rb create mode 100644 db/migrate/20181213185533_create_account_warning_presets.rb (limited to 'db') diff --git a/db/migrate/20181213184704_create_account_warnings.rb b/db/migrate/20181213184704_create_account_warnings.rb new file mode 100644 index 000000000..e768be277 --- /dev/null +++ b/db/migrate/20181213184704_create_account_warnings.rb @@ -0,0 +1,12 @@ +class CreateAccountWarnings < ActiveRecord::Migration[5.2] + def change + create_table :account_warnings do |t| + t.belongs_to :account, foreign_key: { on_delete: :nullify } + t.belongs_to :target_account, foreign_key: { to_table: 'accounts', on_delete: :cascade } + t.integer :action, null: false, default: 0 + t.text :text, null: false, default: '' + + t.timestamps + end + end +end diff --git a/db/migrate/20181213185533_create_account_warning_presets.rb b/db/migrate/20181213185533_create_account_warning_presets.rb new file mode 100644 index 000000000..9c81f1b5e --- /dev/null +++ b/db/migrate/20181213185533_create_account_warning_presets.rb @@ -0,0 +1,9 @@ +class CreateAccountWarningPresets < ActiveRecord::Migration[5.2] + def change + create_table :account_warning_presets do |t| + t.text :text, null: false, default: '' + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 51ac43e1d..51a7b5e74 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: 2018_12_07_011115) do +ActiveRecord::Schema.define(version: 2018_12_13_185533) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -76,6 +76,23 @@ ActiveRecord::Schema.define(version: 2018_12_07_011115) do t.index ["tag_id"], name: "index_account_tag_stats_on_tag_id", unique: true end + create_table "account_warning_presets", force: :cascade do |t| + t.text "text", default: "", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "account_warnings", force: :cascade do |t| + t.bigint "account_id" + t.bigint "target_account_id" + t.integer "action", default: 0, null: false + t.text "text", default: "", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["account_id"], name: "index_account_warnings_on_account_id" + t.index ["target_account_id"], name: "index_account_warnings_on_target_account_id" + end + create_table "accounts", force: :cascade do |t| t.string "username", default: "", null: false t.string "domain" @@ -656,6 +673,8 @@ ActiveRecord::Schema.define(version: 2018_12_07_011115) do add_foreign_key "account_pins", "accounts", on_delete: :cascade add_foreign_key "account_stats", "accounts", on_delete: :cascade add_foreign_key "account_tag_stats", "tags", on_delete: :cascade + add_foreign_key "account_warnings", "accounts", column: "target_account_id", on_delete: :cascade + add_foreign_key "account_warnings", "accounts", on_delete: :nullify add_foreign_key "accounts", "accounts", column: "moved_to_account_id", on_delete: :nullify add_foreign_key "admin_action_logs", "accounts", on_delete: :cascade add_foreign_key "backups", "users", on_delete: :nullify -- cgit