about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-06-29 15:34:36 +0200
committerGitHub <noreply@github.com>2018-06-29 15:34:36 +0200
commitcdb101340a20183a82889f811d9311c370c855e5 (patch)
treedaacd56d1edbf359b0d97a926e90b999ba7f6129 /db
parentfbee9b5ac898e571e384792a92b40fa1524cf127 (diff)
Keyword/phrase filtering (#7905)
* Add keyword filtering

    GET|POST       /api/v1/filters
    GET|PUT|DELETE /api/v1/filters/:id

- Irreversible filters can drop toots from home or notifications
- Other filters can hide toots through the client app
- Filters use a phrase valid in particular contexts, expiration

* Make sure expired filters don't get applied client-side

* Add missing API methods

* Remove "regex filter" from column settings

* Add tests

* Add test for FeedManager

* Add CustomFilter test

* Add UI for managing filters

* Add streaming API event to allow syncing filters

* Fix tests
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20180628181026_create_custom_filters.rb13
-rw-r--r--db/schema.rb14
2 files changed, 26 insertions, 1 deletions
diff --git a/db/migrate/20180628181026_create_custom_filters.rb b/db/migrate/20180628181026_create_custom_filters.rb
new file mode 100644
index 000000000..d19cf2e9d
--- /dev/null
+++ b/db/migrate/20180628181026_create_custom_filters.rb
@@ -0,0 +1,13 @@
+class CreateCustomFilters < ActiveRecord::Migration[5.2]
+  def change
+    create_table :custom_filters do |t|
+      t.belongs_to :account, foreign_key: { on_delete: :cascade }
+      t.datetime :expires_at
+      t.text :phrase, null: false, default: ''
+      t.string :context, array: true, null: false, default: []
+      t.boolean :irreversible, null: false, default: false
+
+      t.timestamps
+    end
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 2853aef94..661fc8179 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_06_17_162849) do
+ActiveRecord::Schema.define(version: 2018_06_28_181026) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -143,6 +143,17 @@ ActiveRecord::Schema.define(version: 2018_06_17_162849) do
     t.index ["shortcode", "domain"], name: "index_custom_emojis_on_shortcode_and_domain", unique: true
   end
 
+  create_table "custom_filters", force: :cascade do |t|
+    t.bigint "account_id"
+    t.datetime "expires_at"
+    t.text "phrase", default: "", null: false
+    t.string "context", default: [], null: false, array: true
+    t.boolean "irreversible", default: false, null: false
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.index ["account_id"], name: "index_custom_filters_on_account_id"
+  end
+
   create_table "domain_blocks", force: :cascade do |t|
     t.string "domain", default: "", null: false
     t.datetime "created_at", null: false
@@ -561,6 +572,7 @@ ActiveRecord::Schema.define(version: 2018_06_17_162849) do
   add_foreign_key "blocks", "accounts", name: "fk_4269e03e65", on_delete: :cascade
   add_foreign_key "conversation_mutes", "accounts", name: "fk_225b4212bb", on_delete: :cascade
   add_foreign_key "conversation_mutes", "conversations", on_delete: :cascade
+  add_foreign_key "custom_filters", "accounts", on_delete: :cascade
   add_foreign_key "favourites", "accounts", name: "fk_5eb6c2b873", on_delete: :cascade
   add_foreign_key "favourites", "statuses", name: "fk_b0e856845e", on_delete: :cascade
   add_foreign_key "follow_requests", "accounts", column: "target_account_id", name: "fk_9291ec025d", on_delete: :cascade