fixes #2230
This commit is contained in:
@@ -45,7 +45,11 @@ div#c-users {
|
|||||||
|
|
||||||
div#a-edit {
|
div#a-edit {
|
||||||
h1 {
|
h1 {
|
||||||
margin-bottom: 0.5em;
|
margin: 0.5em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
margin: 0.5em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.input {
|
div.input {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class Dmail < ActiveRecord::Base
|
|||||||
belongs_to :owner, :class_name => "User"
|
belongs_to :owner, :class_name => "User"
|
||||||
belongs_to :to, :class_name => "User"
|
belongs_to :to, :class_name => "User"
|
||||||
belongs_to :from, :class_name => "User"
|
belongs_to :from, :class_name => "User"
|
||||||
|
before_create :auto_delete_if_filtered
|
||||||
after_create :update_recipient
|
after_create :update_recipient
|
||||||
after_create :send_dmail
|
after_create :send_dmail
|
||||||
attr_accessible :title, :body, :is_deleted, :to_id, :to, :to_name, :creator_ip_addr
|
attr_accessible :title, :body, :is_deleted, :to_id, :to, :to_name, :creator_ip_addr
|
||||||
@@ -192,8 +193,16 @@ class Dmail < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def auto_delete_if_filtered
|
||||||
|
if owner_id != CurrentUser.user.id && to.dmail_filter.try(:filtered?, self)
|
||||||
|
self.is_deleted = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def update_recipient
|
def update_recipient
|
||||||
to.update_attribute(:has_mail, true)
|
unless is_deleted
|
||||||
|
to.update_attribute(:has_mail, true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible_to?(user)
|
def visible_to?(user)
|
||||||
|
|||||||
12
app/models/dmail_filter.rb
Normal file
12
app/models/dmail_filter.rb
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
class DmailFilter < ActiveRecord::Base
|
||||||
|
belongs_to :user
|
||||||
|
attr_accessible :user_id, :words, :as => [:moderator, :janitor, :contributor, :gold, :member, :anonymous, :default, :builder, :admin]
|
||||||
|
|
||||||
|
def filtered?(dmail)
|
||||||
|
dmail.body =~ regexp || dmail.subject =~ regexp
|
||||||
|
end
|
||||||
|
|
||||||
|
def regexp
|
||||||
|
@regexp ||= Regexp.compile(words.scan(/\S+/).map {|x| Regexp.escape(x)}.join("|"))
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -33,7 +33,7 @@ class User < ActiveRecord::Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
attr_accessor :password, :old_password
|
attr_accessor :password, :old_password
|
||||||
attr_accessible :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :enable_sequential_post_navigation, :per_page, :hide_deleted_posts, :style_usernames, :enable_auto_complete, :custom_style, :show_deleted_children, :as => [:moderator, :janitor, :contributor, :gold, :member, :anonymous, :default, :builder, :admin]
|
attr_accessible :dmail_filter_attributes, :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :enable_sequential_post_navigation, :per_page, :hide_deleted_posts, :style_usernames, :enable_auto_complete, :custom_style, :show_deleted_children, :as => [:moderator, :janitor, :contributor, :gold, :member, :anonymous, :default, :builder, :admin]
|
||||||
attr_accessible :level, :as => :admin
|
attr_accessible :level, :as => :admin
|
||||||
validates_length_of :name, :within => 2..100, :on => :create
|
validates_length_of :name, :within => 2..100, :on => :create
|
||||||
validates_format_of :name, :with => /\A[^\s:]+\Z/, :on => :create, :message => "cannot have whitespace or colons"
|
validates_format_of :name, :with => /\A[^\s:]+\Z/, :on => :create, :message => "cannot have whitespace or colons"
|
||||||
@@ -60,12 +60,14 @@ class User < ActiveRecord::Base
|
|||||||
has_many :bans, lambda {order("bans.id desc")}
|
has_many :bans, lambda {order("bans.id desc")}
|
||||||
has_one :recent_ban, lambda {order("bans.id desc")}, :class_name => "Ban"
|
has_one :recent_ban, lambda {order("bans.id desc")}, :class_name => "Ban"
|
||||||
has_one :api_key
|
has_one :api_key
|
||||||
|
has_one :dmail_filter
|
||||||
has_many :subscriptions, lambda {order("tag_subscriptions.name")}, :class_name => "TagSubscription", :foreign_key => "creator_id"
|
has_many :subscriptions, lambda {order("tag_subscriptions.name")}, :class_name => "TagSubscription", :foreign_key => "creator_id"
|
||||||
has_many :note_versions, :foreign_key => "updater_id"
|
has_many :note_versions, :foreign_key => "updater_id"
|
||||||
has_many :dmails, lambda {order("dmails.id desc")}, :foreign_key => "owner_id"
|
has_many :dmails, lambda {order("dmails.id desc")}, :foreign_key => "owner_id"
|
||||||
has_many :saved_searches
|
has_many :saved_searches
|
||||||
belongs_to :inviter, :class_name => "User"
|
belongs_to :inviter, :class_name => "User"
|
||||||
after_update :create_mod_action
|
after_update :create_mod_action
|
||||||
|
accepts_nested_attributes_for :dmail_filter
|
||||||
|
|
||||||
module BanMethods
|
module BanMethods
|
||||||
def validate_ip_addr_is_not_banned
|
def validate_ip_addr_is_not_banned
|
||||||
|
|||||||
@@ -67,6 +67,12 @@
|
|||||||
<span class="hint">A list of tags that you use often. They will appear when using the list of Related Tags.</span>
|
<span class="hint">A list of tags that you use often. They will appear when using the list of Related Tags.</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="input text optional field_with_hint">
|
||||||
|
<label class="text optional" for="user_dmail_filter_attributes_words">Dmail filter</label>
|
||||||
|
<%= text_field_tag "user[dmail_filter_attributes][words]", @user.dmail_filter.try(:words), :id => "user_dmail_filter_attributes_words", :class => "text optional", :size => 40 %>
|
||||||
|
<span class="hint">A list of banned words (space delimited). Any dmail you receive with a banned word will automatically be deleted.</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<%= f.input :custom_style, :label => "Custom <a href='http://en.wikipedia.org/wiki/Cascading_Style_Sheets'>CSS</a> style".html_safe, :hint => "Style to apply to the whole site.", :input_html => {:size => "40x5"} %>
|
<%= f.input :custom_style, :label => "Custom <a href='http://en.wikipedia.org/wiki/Cascading_Style_Sheets'>CSS</a> style".html_safe, :hint => "Style to apply to the whole site.", :input_html => {:size => "40x5"} %>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
|||||||
12
db/migrate/20141120045943_create_dmail_filters.rb
Normal file
12
db/migrate/20141120045943_create_dmail_filters.rb
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
class CreateDmailFilters < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :dmail_filters do |t|
|
||||||
|
t.integer :user_id, :null => false
|
||||||
|
t.text :words, :null => false
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index :dmail_filters, :user_id, :unique => true
|
||||||
|
end
|
||||||
|
end
|
||||||
235
db/structure.sql
235
db/structure.sql
@@ -3,7 +3,6 @@
|
|||||||
--
|
--
|
||||||
|
|
||||||
SET statement_timeout = 0;
|
SET statement_timeout = 0;
|
||||||
SET lock_timeout = 0;
|
|
||||||
SET client_encoding = 'UTF8';
|
SET client_encoding = 'UTF8';
|
||||||
SET standard_conforming_strings = on;
|
SET standard_conforming_strings = on;
|
||||||
SET check_function_bodies = false;
|
SET check_function_bodies = false;
|
||||||
@@ -422,8 +421,8 @@ CREATE TABLE advertisement_hits (
|
|||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
advertisement_id integer NOT NULL,
|
advertisement_id integer NOT NULL,
|
||||||
ip_addr inet NOT NULL,
|
ip_addr inet NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -460,8 +459,8 @@ CREATE TABLE advertisements (
|
|||||||
height integer NOT NULL,
|
height integer NOT NULL,
|
||||||
file_name character varying(255) NOT NULL,
|
file_name character varying(255) NOT NULL,
|
||||||
is_work_safe boolean DEFAULT false NOT NULL,
|
is_work_safe boolean DEFAULT false NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -491,8 +490,8 @@ ALTER SEQUENCE advertisements_id_seq OWNED BY advertisements.id;
|
|||||||
CREATE TABLE amazon_backups (
|
CREATE TABLE amazon_backups (
|
||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
last_id integer,
|
last_id integer,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -558,8 +557,8 @@ CREATE TABLE artist_commentaries (
|
|||||||
original_description text,
|
original_description text,
|
||||||
translated_title text,
|
translated_title text,
|
||||||
translated_description text,
|
translated_description text,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -595,8 +594,8 @@ CREATE TABLE artist_commentary_versions (
|
|||||||
original_description text,
|
original_description text,
|
||||||
translated_title text,
|
translated_title text,
|
||||||
translated_description text,
|
translated_description text,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -628,8 +627,8 @@ CREATE TABLE artist_urls (
|
|||||||
artist_id integer NOT NULL,
|
artist_id integer NOT NULL,
|
||||||
url text NOT NULL,
|
url text NOT NULL,
|
||||||
normalized_url text NOT NULL,
|
normalized_url text NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -667,8 +666,8 @@ CREATE TABLE artist_versions (
|
|||||||
group_name character varying(255),
|
group_name character varying(255),
|
||||||
url_string text,
|
url_string text,
|
||||||
is_banned boolean DEFAULT false NOT NULL,
|
is_banned boolean DEFAULT false NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -704,8 +703,8 @@ CREATE TABLE artists (
|
|||||||
other_names text,
|
other_names text,
|
||||||
other_names_index tsvector,
|
other_names_index tsvector,
|
||||||
group_name character varying(255),
|
group_name character varying(255),
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -738,8 +737,8 @@ CREATE TABLE bans (
|
|||||||
reason text NOT NULL,
|
reason text NOT NULL,
|
||||||
banner_id integer NOT NULL,
|
banner_id integer NOT NULL,
|
||||||
expires_at timestamp without time zone NOT NULL,
|
expires_at timestamp without time zone NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -805,8 +804,8 @@ CREATE TABLE comment_votes (
|
|||||||
comment_id integer NOT NULL,
|
comment_id integer NOT NULL,
|
||||||
user_id integer NOT NULL,
|
user_id integer NOT NULL,
|
||||||
score integer NOT NULL,
|
score integer NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -841,8 +840,8 @@ CREATE TABLE comments (
|
|||||||
ip_addr inet NOT NULL,
|
ip_addr inet NOT NULL,
|
||||||
body_index tsvector NOT NULL,
|
body_index tsvector NOT NULL,
|
||||||
score integer DEFAULT 0 NOT NULL,
|
score integer DEFAULT 0 NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone NOT NULL,
|
||||||
updater_id integer,
|
updater_id integer,
|
||||||
updater_ip_addr inet,
|
updater_ip_addr inet,
|
||||||
do_not_bump_post boolean DEFAULT false NOT NULL
|
do_not_bump_post boolean DEFAULT false NOT NULL
|
||||||
@@ -882,8 +881,8 @@ CREATE TABLE delayed_jobs (
|
|||||||
locked_at timestamp without time zone,
|
locked_at timestamp without time zone,
|
||||||
failed_at timestamp without time zone,
|
failed_at timestamp without time zone,
|
||||||
locked_by character varying(255),
|
locked_by character varying(255),
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone NOT NULL,
|
||||||
queue character varying(255)
|
queue character varying(255)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -907,6 +906,38 @@ CREATE SEQUENCE delayed_jobs_id_seq
|
|||||||
ALTER SEQUENCE delayed_jobs_id_seq OWNED BY delayed_jobs.id;
|
ALTER SEQUENCE delayed_jobs_id_seq OWNED BY delayed_jobs.id;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: dmail_filters; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE dmail_filters (
|
||||||
|
id integer NOT NULL,
|
||||||
|
user_id integer NOT NULL,
|
||||||
|
words text NOT NULL,
|
||||||
|
created_at timestamp without time zone,
|
||||||
|
updated_at timestamp without time zone
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: dmail_filters_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE SEQUENCE 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 dmail_filters_id_seq OWNED BY dmail_filters.id;
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: dmails; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
-- Name: dmails; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
||||||
--
|
--
|
||||||
@@ -921,8 +952,8 @@ CREATE TABLE dmails (
|
|||||||
message_index tsvector NOT NULL,
|
message_index tsvector NOT NULL,
|
||||||
is_read boolean DEFAULT false NOT NULL,
|
is_read boolean DEFAULT false NOT NULL,
|
||||||
is_deleted boolean DEFAULT false NOT NULL,
|
is_deleted boolean DEFAULT false NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone NOT NULL,
|
||||||
creator_ip_addr inet DEFAULT '127.0.0.1'::inet NOT NULL
|
creator_ip_addr inet DEFAULT '127.0.0.1'::inet NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1988,8 +2019,8 @@ CREATE TABLE forum_posts (
|
|||||||
body text NOT NULL,
|
body text NOT NULL,
|
||||||
text_index tsvector NOT NULL,
|
text_index tsvector NOT NULL,
|
||||||
is_deleted boolean DEFAULT false NOT NULL,
|
is_deleted boolean DEFAULT false NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -2091,8 +2122,8 @@ CREATE TABLE forum_topics (
|
|||||||
is_locked boolean DEFAULT false NOT NULL,
|
is_locked boolean DEFAULT false NOT NULL,
|
||||||
is_deleted boolean DEFAULT false NOT NULL,
|
is_deleted boolean DEFAULT false NOT NULL,
|
||||||
text_index tsvector NOT NULL,
|
text_index tsvector NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone NOT NULL,
|
||||||
category_id integer DEFAULT 0 NOT NULL
|
category_id integer DEFAULT 0 NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -2125,8 +2156,8 @@ CREATE TABLE ip_bans (
|
|||||||
creator_id integer NOT NULL,
|
creator_id integer NOT NULL,
|
||||||
ip_addr inet NOT NULL,
|
ip_addr inet NOT NULL,
|
||||||
reason text NOT NULL,
|
reason text NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -2158,8 +2189,8 @@ CREATE TABLE janitor_trials (
|
|||||||
creator_id integer NOT NULL,
|
creator_id integer NOT NULL,
|
||||||
user_id integer NOT NULL,
|
user_id integer NOT NULL,
|
||||||
original_level integer NOT NULL,
|
original_level integer NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -2190,8 +2221,8 @@ CREATE TABLE key_values (
|
|||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
key character varying(255) NOT NULL,
|
key character varying(255) NOT NULL,
|
||||||
value text,
|
value text,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -2222,8 +2253,8 @@ CREATE TABLE mod_actions (
|
|||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
creator_id integer NOT NULL,
|
creator_id integer NOT NULL,
|
||||||
description text NOT NULL,
|
description text NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -2255,8 +2286,8 @@ CREATE TABLE news_updates (
|
|||||||
message text NOT NULL,
|
message text NOT NULL,
|
||||||
creator_id integer NOT NULL,
|
creator_id integer NOT NULL,
|
||||||
updater_id integer NOT NULL,
|
updater_id integer NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -2295,8 +2326,8 @@ CREATE TABLE note_versions (
|
|||||||
height integer NOT NULL,
|
height integer NOT NULL,
|
||||||
is_active boolean DEFAULT true NOT NULL,
|
is_active boolean DEFAULT true NOT NULL,
|
||||||
body text NOT NULL,
|
body text NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone NOT NULL,
|
||||||
version integer DEFAULT 0 NOT NULL
|
version integer DEFAULT 0 NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -2335,8 +2366,8 @@ CREATE TABLE notes (
|
|||||||
is_active boolean DEFAULT true NOT NULL,
|
is_active boolean DEFAULT true NOT NULL,
|
||||||
body text NOT NULL,
|
body text NOT NULL,
|
||||||
body_index tsvector NOT NULL,
|
body_index tsvector NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone NOT NULL,
|
||||||
version integer DEFAULT 0 NOT NULL
|
version integer DEFAULT 0 NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -2368,8 +2399,7 @@ CREATE TABLE pixiv_ugoira_frame_data (
|
|||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
post_id integer,
|
post_id integer,
|
||||||
data text NOT NULL,
|
data text NOT NULL,
|
||||||
content_type character varying(255) NOT NULL,
|
content_type character varying(255) NOT NULL
|
||||||
console_log text
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -2402,8 +2432,8 @@ CREATE TABLE pool_versions (
|
|||||||
post_ids text DEFAULT ''::text NOT NULL,
|
post_ids text DEFAULT ''::text NOT NULL,
|
||||||
updater_id integer NOT NULL,
|
updater_id integer NOT NULL,
|
||||||
updater_ip_addr inet NOT NULL,
|
updater_ip_addr inet NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone NOT NULL,
|
||||||
name character varying(255)
|
name character varying(255)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -2440,8 +2470,8 @@ CREATE TABLE pools (
|
|||||||
post_ids text DEFAULT ''::text NOT NULL,
|
post_ids text DEFAULT ''::text NOT NULL,
|
||||||
post_count integer DEFAULT 0 NOT NULL,
|
post_count integer DEFAULT 0 NOT NULL,
|
||||||
is_deleted boolean DEFAULT false NOT NULL,
|
is_deleted boolean DEFAULT false NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone NOT NULL,
|
||||||
category character varying(255) DEFAULT 'series'::character varying NOT NULL
|
category character varying(255) DEFAULT 'series'::character varying NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -2475,8 +2505,8 @@ CREATE TABLE post_appeals (
|
|||||||
creator_id integer NOT NULL,
|
creator_id integer NOT NULL,
|
||||||
creator_ip_addr integer NOT NULL,
|
creator_ip_addr integer NOT NULL,
|
||||||
reason text,
|
reason text,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -2507,8 +2537,8 @@ CREATE TABLE post_disapprovals (
|
|||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
user_id integer NOT NULL,
|
user_id integer NOT NULL,
|
||||||
post_id integer NOT NULL,
|
post_id integer NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -2542,8 +2572,8 @@ CREATE TABLE post_flags (
|
|||||||
creator_ip_addr inet NOT NULL,
|
creator_ip_addr inet NOT NULL,
|
||||||
reason text,
|
reason text,
|
||||||
is_resolved boolean DEFAULT false NOT NULL,
|
is_resolved boolean DEFAULT false NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -2572,8 +2602,8 @@ ALTER SEQUENCE post_flags_id_seq OWNED BY post_flags.id;
|
|||||||
|
|
||||||
CREATE TABLE post_versions (
|
CREATE TABLE post_versions (
|
||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone NOT NULL,
|
||||||
post_id integer NOT NULL,
|
post_id integer NOT NULL,
|
||||||
tags text DEFAULT ''::text NOT NULL,
|
tags text DEFAULT ''::text NOT NULL,
|
||||||
rating character(1),
|
rating character(1),
|
||||||
@@ -2612,8 +2642,8 @@ CREATE TABLE post_votes (
|
|||||||
post_id integer NOT NULL,
|
post_id integer NOT NULL,
|
||||||
user_id integer NOT NULL,
|
user_id integer NOT NULL,
|
||||||
score integer NOT NULL,
|
score integer NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -2642,8 +2672,8 @@ ALTER SEQUENCE post_votes_id_seq OWNED BY post_votes.id;
|
|||||||
|
|
||||||
CREATE TABLE posts (
|
CREATE TABLE posts (
|
||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone NOT NULL,
|
||||||
up_score integer DEFAULT 0 NOT NULL,
|
up_score integer DEFAULT 0 NOT NULL,
|
||||||
down_score integer DEFAULT 0 NOT NULL,
|
down_score integer DEFAULT 0 NOT NULL,
|
||||||
score integer DEFAULT 0 NOT NULL,
|
score integer DEFAULT 0 NOT NULL,
|
||||||
@@ -2758,8 +2788,8 @@ CREATE TABLE tag_aliases (
|
|||||||
creator_ip_addr inet NOT NULL,
|
creator_ip_addr inet NOT NULL,
|
||||||
forum_topic_id integer,
|
forum_topic_id integer,
|
||||||
status text DEFAULT 'pending'::text NOT NULL,
|
status text DEFAULT 'pending'::text NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -2795,8 +2825,8 @@ CREATE TABLE tag_implications (
|
|||||||
creator_ip_addr inet NOT NULL,
|
creator_ip_addr inet NOT NULL,
|
||||||
forum_topic_id integer,
|
forum_topic_id integer,
|
||||||
status text DEFAULT 'pending'::text NOT NULL,
|
status text DEFAULT 'pending'::text NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -2832,8 +2862,8 @@ CREATE TABLE tag_subscriptions (
|
|||||||
is_public boolean DEFAULT true NOT NULL,
|
is_public boolean DEFAULT true NOT NULL,
|
||||||
last_accessed_at timestamp without time zone,
|
last_accessed_at timestamp without time zone,
|
||||||
is_opted_in boolean DEFAULT false NOT NULL,
|
is_opted_in boolean DEFAULT false NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -2867,8 +2897,8 @@ CREATE TABLE tags (
|
|||||||
category integer DEFAULT 0 NOT NULL,
|
category integer DEFAULT 0 NOT NULL,
|
||||||
related_tags text,
|
related_tags text,
|
||||||
related_tags_updated_at timestamp without time zone,
|
related_tags_updated_at timestamp without time zone,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone NOT NULL,
|
||||||
is_locked boolean DEFAULT false NOT NULL
|
is_locked boolean DEFAULT false NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -2901,8 +2931,8 @@ CREATE TABLE transaction_log_items (
|
|||||||
category character varying(255),
|
category character varying(255),
|
||||||
user_id integer,
|
user_id integer,
|
||||||
data text,
|
data text,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -2942,8 +2972,8 @@ CREATE TABLE uploads (
|
|||||||
backtrace text,
|
backtrace text,
|
||||||
post_id integer,
|
post_id integer,
|
||||||
md5_confirmation character varying(255),
|
md5_confirmation character varying(255),
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone NOT NULL,
|
||||||
server text,
|
server text,
|
||||||
parent_id integer
|
parent_id integer
|
||||||
);
|
);
|
||||||
@@ -2978,8 +3008,8 @@ CREATE TABLE user_feedback (
|
|||||||
creator_id integer NOT NULL,
|
creator_id integer NOT NULL,
|
||||||
category character varying(255) NOT NULL,
|
category character varying(255) NOT NULL,
|
||||||
body text NOT NULL,
|
body text NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -3015,8 +3045,8 @@ CREATE TABLE user_name_change_requests (
|
|||||||
desired_name character varying(255),
|
desired_name character varying(255),
|
||||||
change_reason text,
|
change_reason text,
|
||||||
rejection_reason text,
|
rejection_reason text,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -3047,8 +3077,8 @@ CREATE TABLE user_password_reset_nonces (
|
|||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
key character varying(255) NOT NULL,
|
key character varying(255) NOT NULL,
|
||||||
email character varying(255) NOT NULL,
|
email character varying(255) NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -3077,8 +3107,8 @@ ALTER SEQUENCE user_password_reset_nonces_id_seq OWNED BY user_password_reset_no
|
|||||||
|
|
||||||
CREATE TABLE users (
|
CREATE TABLE users (
|
||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone NOT NULL,
|
||||||
name character varying(255) NOT NULL,
|
name character varying(255) NOT NULL,
|
||||||
password_hash character varying(255) NOT NULL,
|
password_hash character varying(255) NOT NULL,
|
||||||
email character varying(255),
|
email character varying(255),
|
||||||
@@ -3136,8 +3166,8 @@ CREATE TABLE wiki_page_versions (
|
|||||||
title character varying(255) NOT NULL,
|
title character varying(255) NOT NULL,
|
||||||
body text NOT NULL,
|
body text NOT NULL,
|
||||||
is_locked boolean NOT NULL,
|
is_locked boolean NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone NOT NULL,
|
||||||
other_names text
|
other_names text
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -3172,8 +3202,8 @@ CREATE TABLE wiki_pages (
|
|||||||
body text NOT NULL,
|
body text NOT NULL,
|
||||||
body_index tsvector NOT NULL,
|
body_index tsvector NOT NULL,
|
||||||
is_locked boolean DEFAULT false NOT NULL,
|
is_locked boolean DEFAULT false NOT NULL,
|
||||||
created_at timestamp without time zone,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone,
|
updated_at timestamp without time zone NOT NULL,
|
||||||
updater_id integer,
|
updater_id integer,
|
||||||
other_names text,
|
other_names text,
|
||||||
other_names_index tsvector
|
other_names_index tsvector
|
||||||
@@ -3297,6 +3327,13 @@ ALTER TABLE ONLY comments ALTER COLUMN id SET DEFAULT nextval('comments_id_seq':
|
|||||||
ALTER TABLE ONLY delayed_jobs ALTER COLUMN id SET DEFAULT nextval('delayed_jobs_id_seq'::regclass);
|
ALTER TABLE ONLY delayed_jobs ALTER COLUMN id SET DEFAULT nextval('delayed_jobs_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY dmail_filters ALTER COLUMN id SET DEFAULT nextval('dmail_filters_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
@@ -4354,6 +4391,14 @@ ALTER TABLE ONLY delayed_jobs
|
|||||||
ADD CONSTRAINT delayed_jobs_pkey PRIMARY KEY (id);
|
ADD CONSTRAINT delayed_jobs_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: dmail_filters_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY dmail_filters
|
||||||
|
ADD CONSTRAINT dmail_filters_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: dmails_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
-- Name: dmails_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
|
||||||
--
|
--
|
||||||
@@ -4837,6 +4882,13 @@ CREATE INDEX index_comments_on_post_id ON comments USING btree (post_id);
|
|||||||
CREATE INDEX index_delayed_jobs_on_run_at ON delayed_jobs USING btree (run_at);
|
CREATE INDEX index_delayed_jobs_on_run_at ON delayed_jobs USING btree (run_at);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: index_dmail_filters_on_user_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE UNIQUE INDEX index_dmail_filters_on_user_id ON dmail_filters USING btree (user_id);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: index_dmails_on_creator_ip_addr; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
-- Name: index_dmails_on_creator_ip_addr; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||||
--
|
--
|
||||||
@@ -6300,6 +6352,13 @@ CREATE INDEX index_forum_subscriptions_on_user_id ON forum_subscriptions USING b
|
|||||||
CREATE INDEX index_forum_topic_visits_on_forum_topic_id ON forum_topic_visits USING btree (forum_topic_id);
|
CREATE INDEX index_forum_topic_visits_on_forum_topic_id ON forum_topic_visits USING btree (forum_topic_id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: index_forum_topic_visits_on_last_read_at; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE INDEX index_forum_topic_visits_on_last_read_at ON forum_topic_visits USING btree (last_read_at);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: index_forum_topic_visits_on_user_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
-- Name: index_forum_topic_visits_on_user_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||||
--
|
--
|
||||||
@@ -7113,5 +7172,5 @@ INSERT INTO schema_migrations (version) VALUES ('20141009231234');
|
|||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20141017231608');
|
INSERT INTO schema_migrations (version) VALUES ('20141017231608');
|
||||||
|
|
||||||
INSERT INTO schema_migrations (version) VALUES ('20141028202032');
|
INSERT INTO schema_migrations (version) VALUES ('20141120045943');
|
||||||
|
|
||||||
|
|||||||
7
test/models/dmail_filter_test.rb
Normal file
7
test/models/dmail_filter_test.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class DmailFilterTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
||||||
@@ -16,6 +16,23 @@ class DmailTest < ActiveSupport::TestCase
|
|||||||
CurrentUser.user = nil
|
CurrentUser.user = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "filter" do
|
||||||
|
setup do
|
||||||
|
@recipient = FactoryGirl.create(:user)
|
||||||
|
@recipient.create_dmail_filter(:words => "banned")
|
||||||
|
@dmail = FactoryGirl.build(:dmail, :title => "xxx", :owner => @recipient, :body => "banned word here", :to => @recipient)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "detect banned words" do
|
||||||
|
assert(@recipient.dmail_filter.filtered?(@dmail))
|
||||||
|
end
|
||||||
|
|
||||||
|
should "autodelete if it has a banned word" do
|
||||||
|
@dmail.save
|
||||||
|
assert(@dmail.is_deleted)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "from a banned user" do
|
context "from a banned user" do
|
||||||
setup do
|
setup do
|
||||||
@user.update_attribute(:is_banned, true)
|
@user.update_attribute(:is_banned, true)
|
||||||
|
|||||||
Reference in New Issue
Block a user