A list of banned words or users (space delimited). Any message you receive with a banned word will automatically be deleted. Make sure user names have no spaces in them (replace with underscores).
-
-<% content_for(:page_title) do %>
- Edit Message Filters - <%= Danbooru.config.app_name %>
-<% end %>
diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb
index 9de157b6c..e7fccae9d 100644
--- a/app/views/users/edit.html.erb
+++ b/app/views/users/edit.html.erb
@@ -65,13 +65,6 @@
<%= f.input :disable_responsive_mode, :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false, :hint => "Disable alternative layout for mobile and tablet" %>
<%= f.input :opt_out_tracking, :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false, :hint => "Opt out of tracking" %>
-
-
- <%= hidden_field_tag "user[dmail_filter_attributes][id]", @user.dmail_filter.try(:id) %>
- <%= text_field_tag "user[dmail_filter_attributes][words]", @user.dmail_filter.try(:words), :id => "user_dmail_filter_attributes_words", :class => "text optional", :size => 40 %>
- A list of banned words (space delimited). Any dmail you receive with a banned word will automatically be deleted.
-
-
<%= f.input :favorite_tags, :label => "Frequent tags", :hint => "A list of tags that you use often. They will appear when using the list of Related Tags.", :input_html => { :rows => 5, :data => { :autocomplete => "tag-query" } } %>
<%= f.input :custom_style, :label => "Custom CSS style".html_safe, :hint => "CSS rules to apply to the whole site.", :input_html => {:size => "40x5"} %>
diff --git a/config/routes.rb b/config/routes.rb
index f7a750ca3..7bb4ae82b 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -59,7 +59,6 @@ Rails.application.routes.draw do
resource :password_reset, :only => [:new, :create, :edit, :update]
resource :deletion, :only => [:show, :destroy]
resource :email_change, :only => [:new, :create]
- resource :dmail_filter, :only => [:edit, :update]
resource :api_key, :only => [:show, :view, :update, :destroy] do
post :view
end
diff --git a/db/migrate/20200119184442_drop_dmail_filters.rb b/db/migrate/20200119184442_drop_dmail_filters.rb
new file mode 100644
index 000000000..57e6800ba
--- /dev/null
+++ b/db/migrate/20200119184442_drop_dmail_filters.rb
@@ -0,0 +1,7 @@
+require_relative "20141120045943_create_dmail_filters"
+
+class DropDmailFilters < ActiveRecord::Migration[6.0]
+ def change
+ revert CreateDmailFilters
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index b545e73e6..3f524b6e9 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -807,38 +807,6 @@ CREATE SEQUENCE public.delayed_jobs_id_seq
ALTER SEQUENCE public.delayed_jobs_id_seq OWNED BY public.delayed_jobs.id;
---
--- Name: dmail_filters; Type: TABLE; Schema: public; Owner: -
---
-
-CREATE TABLE public.dmail_filters (
- id integer NOT NULL,
- user_id integer NOT NULL,
- words text NOT NULL,
- created_at timestamp without time zone NOT NULL,
- updated_at timestamp without time zone NOT NULL
-);
-
-
---
--- Name: dmail_filters_id_seq; Type: SEQUENCE; Schema: public; Owner: -
---
-
-CREATE SEQUENCE public.dmail_filters_id_seq
- START WITH 1
- INCREMENT BY 1
- NO MINVALUE
- NO MAXVALUE
- CACHE 1;
-
-
---
--- Name: dmail_filters_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
---
-
-ALTER SEQUENCE public.dmail_filters_id_seq OWNED BY public.dmail_filters.id;
-
-
--
-- Name: dmails; Type: TABLE; Schema: public; Owner: -
--
@@ -3330,13 +3298,6 @@ ALTER TABLE ONLY public.comments ALTER COLUMN id SET DEFAULT nextval('public.com
ALTER TABLE ONLY public.delayed_jobs ALTER COLUMN id SET DEFAULT nextval('public.delayed_jobs_id_seq'::regclass);
---
--- Name: dmail_filters id; Type: DEFAULT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY public.dmail_filters ALTER COLUMN id SET DEFAULT nextval('public.dmail_filters_id_seq'::regclass);
-
-
--
-- Name: dmails id; Type: DEFAULT; Schema: public; Owner: -
--
@@ -4385,14 +4346,6 @@ ALTER TABLE ONLY public.delayed_jobs
ADD CONSTRAINT delayed_jobs_pkey PRIMARY KEY (id);
---
--- Name: dmail_filters dmail_filters_pkey; Type: CONSTRAINT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY public.dmail_filters
- ADD CONSTRAINT dmail_filters_pkey PRIMARY KEY (id);
-
-
--
-- Name: dmails dmails_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
@@ -4932,13 +4885,6 @@ CREATE INDEX index_delayed_jobs_on_locked_by ON public.delayed_jobs USING btree
CREATE INDEX index_delayed_jobs_on_run_at ON public.delayed_jobs USING btree (run_at);
---
--- Name: index_dmail_filters_on_user_id; Type: INDEX; Schema: public; Owner: -
---
-
-CREATE UNIQUE INDEX index_dmail_filters_on_user_id ON public.dmail_filters USING btree (user_id);
-
-
--
-- Name: index_dmails_on_created_at; Type: INDEX; Schema: public; Owner: -
--
@@ -7479,6 +7425,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200114204550'),
('20200115010442'),
('20200117220602'),
-('20200118015014');
+('20200118015014'),
+('20200119184442');
diff --git a/test/functional/maintenance/user/dmail_filters_controller_test.rb b/test/functional/maintenance/user/dmail_filters_controller_test.rb
deleted file mode 100644
index 2ca6c8b56..000000000
--- a/test/functional/maintenance/user/dmail_filters_controller_test.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require "test_helper"
-
-module Maintenance
- module User
- class DmailFiltersControllerTest < ActionDispatch::IntegrationTest
- context "The dmail filters controller" do
- setup do
- @user1 = create(:user)
- @user2 = create(:user)
- end
-
- context "update action" do
- setup do
- as(@user1) do
- @dmail = create(:dmail, owner: @user1)
- end
- end
-
- should "not allow a user to create a filter belonging to another user" do
- params = {
- :dmail_id => @dmail.id,
- :dmail_filter => {
- :words => "owned",
- :user_id => @user2.id
- }
- }
-
- put_auth maintenance_user_dmail_filter_path, @user1, params: params
- assert_not_equal("owned", @user2.reload.dmail_filter.try(&:words))
- end
- end
- end
- end
- end
-end
diff --git a/test/unit/dmail_filter_test.rb b/test/unit/dmail_filter_test.rb
deleted file mode 100644
index c476ed6b5..000000000
--- a/test/unit/dmail_filter_test.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-require 'test_helper'
-
-class DmailFilterTest < ActiveSupport::TestCase
- def setup
- super
-
- @receiver = FactoryBot.create(:user)
- @sender = FactoryBot.create(:user)
- end
-
- def create_dmail(body, title)
- CurrentUser.scoped(@sender, "127.0.0.1") do
- Dmail.create_split(:to_id => @receiver.id, :body => body, :title => title)
- end
- end
-
- context "a dmail filter for a word" do
- setup do
- @dmail_filter = @receiver.create_dmail_filter(:words => "banned")
- end
-
- should "filter on that word in the body" do
- create_dmail("banned", "okay")
- assert_equal(true, @receiver.dmails.last.is_read?)
- end
-
- should "filter on that word in the title" do
- create_dmail("okay", "banned")
- assert_equal(true, @receiver.dmails.last.is_read?)
- end
-
- should "be case insensitive" do
- create_dmail("Banned.", "okay")
- assert_equal(true, @receiver.dmails.last.is_read?)
- end
- end
-
- context "a dmail filter for a user name" do
- setup do
- @dmail_filter = @receiver.create_dmail_filter(:words => @sender.name)
- end
-
- should "filter on the sender" do
- create_dmail("okay", "okay")
- assert_equal(true, @receiver.dmails.last.is_read?)
- end
- end
-
- context "a dmail filter containing multiple words" do
- should "filter dmails containing any of the words" do
- @receiver.create_dmail_filter(words: "foo bar spam")
- create_dmail("this is a test (not *SPAM*)", "hello world")
-
- assert_equal(true, @receiver.dmails.last.is_read?)
- end
- end
-end
diff --git a/test/unit/dmail_test.rb b/test/unit/dmail_test.rb
index 98b4a5909..ab7fccc19 100644
--- a/test/unit/dmail_test.rb
+++ b/test/unit/dmail_test.rb
@@ -43,49 +43,6 @@ class DmailTest < ActiveSupport::TestCase
end
end
- context "filter" do
- setup do
- @recipient = FactoryBot.create(:user)
- @recipient.create_dmail_filter(:words => "banned")
- @dmail = FactoryBot.build(:dmail, :title => "xxx", :owner => @recipient, :body => "banned word here", :to => @recipient, :from => @user)
- end
-
- should "detect banned words" do
- assert(@recipient.dmail_filter.filtered?(@dmail))
- end
-
- should "autoread if it has a banned word" do
- @dmail.save
- assert_equal(true, @dmail.is_read?)
- end
-
- should "not update the recipient's has_mail if filtered" do
- @dmail.save
- @recipient.reload
- assert_equal(false, @recipient.has_mail?)
- end
-
- should "be ignored when sender is a moderator" do
- CurrentUser.scoped(FactoryBot.create(:moderator_user), "127.0.0.1") do
- @dmail = FactoryBot.create(:dmail, :owner => @recipient, :body => "banned word here", :to => @recipient)
- end
-
- assert_equal(false, @recipient.dmail_filter.filtered?(@dmail))
- assert_equal(false, @dmail.is_read?)
- assert_equal(true, @recipient.has_mail?)
- end
-
- context "that is empty" do
- setup do
- @recipient.dmail_filter.update(words: " ")
- end
-
- should "not filter everything" do
- assert(!@recipient.dmail_filter.filtered?(@dmail))
- end
- end
- end
-
context "from a banned user" do
setup do
@user.update_attribute(:is_banned, true)