Merge branch 'dev_daiao' into dev_aliyun

dev_cxt
daiao 5 years ago
commit 6ca1cb1fa2

@ -106,3 +106,6 @@ gem 'omniauth-oauth2', '~> 1.6.0'
# global var
gem 'request_store'
# 敏感词汇
gem 'harmonious_dictionary', '~> 0.0.1'

@ -85,7 +85,7 @@ class DiscussesController < ApplicationController
:hidden => !current_user.admin?) # 管理员回复的能够显示
rescue Exception => e
uid_logger_error("create discuss failed : #{e.message}")
raise Educoder::TipException.new("评论异常")
raise Educoder::TipException.new("评论异常,原因:#{e.message}")
end
end
@ -97,7 +97,7 @@ class DiscussesController < ApplicationController
:dis_type => @discuss.dis_type, :position => @discuss.position)
rescue Exception => e
uid_logger_error("reply discuss failed : #{e.message}")
raise Educoder::TipException.new("回复评论异常")
raise Educoder::TipException.new("回复评论异常,原因: #{e.message}")
end
end

@ -81,6 +81,8 @@ class Course < ApplicationRecord
# 老版的members弃用 现用course_members
has_many :members
validate :validate_sensitive_string
scope :hidden, ->(is_hidden = true) { where(is_hidden: is_hidden) }
scope :ended, ->(is_end = true) { where(is_end: is_end) }
scope :processing, -> { where(is_end: false) }
@ -435,4 +437,8 @@ class Course < ApplicationRecord
self.laboratory = Laboratory.current if laboratory_id.blank?
end
def validate_sensitive_string
raise("课堂名称包含敏感词汇,请重新输入") unless HarmoniousDictionary.clean?(name)
end
end

@ -6,4 +6,10 @@ class CourseList < ApplicationRecord
has_many :gtask_banks
has_many :gtopic_banks
belongs_to :user
validate :validate_sensitive_string
def validate_sensitive_string
raise("课程名称包含敏感词汇,请重新输入") unless HarmoniousDictionary.clean?(name)
end
end

@ -11,6 +11,8 @@ class Discuss < ApplicationRecord
belongs_to :dis, polymorphic: true
belongs_to :challenge, optional: true
validate :validate_sensitive_string
after_create :send_tiding
scope :children, -> (discuss_id){ where(parent_id: discuss_id).includes(:user).reorder(created_at: :asc) }
@ -69,4 +71,8 @@ class Discuss < ApplicationRecord
}
tidings.create!(base_attrs.merge(user_id: send_user_id))
end
def validate_sensitive_string
raise("内容包含敏感词汇,请重新输入") unless HarmoniousDictionary.clean?(content)
end
end

@ -16,6 +16,7 @@ class Memo < ApplicationRecord
has_many :children, foreign_key: :parent_id, class_name: 'Memo'
has_many :attachments, as: :container, dependent: :destroy
has_many :tidings, as: :container, dependent: :destroy
validate :validate_sensitive_string
scope :field_for_list, lambda{
select([:id, :subject, :author_id, :sticky, :updated_at, :language, :reward, :all_replies_count, :viewed_count, :forum_id])
@ -54,4 +55,9 @@ class Memo < ApplicationRecord
self.tidings << Tiding.new(tiding_attr)
end
def validate_sensitive_string
raise("标题包含敏感词汇,请重新输入") unless HarmoniousDictionary.clean?(subject)
raise("内容包含敏感词汇,请重新输入") unless HarmoniousDictionary.clean?(content)
end
end

@ -178,13 +178,8 @@ class User < ApplicationRecord
validates_uniqueness_of :phone, :if => Proc.new { |user| user.phone_changed? && user.phone.present? }, case_sensitive: false
validates_length_of :login, maximum: LOGIN_LENGTH_LIMIT
validates_length_of :mail, maximum: MAIL_LENGTH_LMIT
# validates_format_of :mail, with: VALID_EMAIL_REGEX, multiline: true
# validates_format_of :phone, with: VALID_PHONE_REGEX, multiline: true
validate :validate_sensitive_string
validate :validate_password_length
#validate :validate_ID_number
#validates_format_of :ID_number, with: VALID_NUMBER_REGEX, multiline: true, message: "身份证号格式不对"
# validates :nickname, presence: true, length: { maximum: 10 }
# validates :lastname, presence: true
# 删除自动登录的token一旦退出下次会提示需要登录
def delete_autologin_token(value)
@ -727,6 +722,11 @@ class User < ApplicationRecord
end
end
def validate_sensitive_string
raise("真实姓名包含敏感词汇,请重新输入") unless HarmoniousDictionary.clean?(lastname)
raise("昵称包含敏感词汇,请重新输入") unless HarmoniousDictionary.clean?(nickname)
end
def set_laboratory
return unless new_record?

File diff suppressed because it is too large Load Diff

@ -0,0 +1,66 @@
6-4tianwang
89-64cdjp
ADMIN
Administrator
asshole
BLOWJOB
chinaliberal
chinamz
chinesenewsnet
Clockgemstone
creaders
Crestbone
dajiyuan
dfdz
DICK
falun
falundafa
Feelmistone
freechina
freenet
fuck
gcd
Gruepin
Guichuideng
HACKING
hongzhi
hrichina
HUANET
hypermart.net
incest
jiangdongriji
jiaochuang
jiaochun
KEFU
KISSMYASS
lihongzhi
minghui
minghuinews
nacb
Neckromancer
NMIS
PAPER64
penis
qiangjian
renminbao
renmingbao
SHIT
SUCKPENIS
taip
tibetalk
triangle
triangleboy
Tringel
UltraSurf
ustibet
voachinese
wangce
WEBZEN
wstaiji
xinsheng
YUMING
zangdu
ZHENGJIAN
ZHENGJIANWANG
ZHENSHANREN
zhuanfalun

@ -0,0 +1,67 @@
---
- 6-4tianwang
- 89-64cdjp
- ADMIN
- Administrator
- asshole
- BLOWJOB
- chinaliberal
- chinamz
- chinesenewsnet
- Clockgemstone
- creaders
- Crestbone
- dajiyuan
- dfdz
- DICK
- falun
- falundafa
- Feelmistone
- freechina
- freenet
- fuck
- gcd
- Gruepin
- Guichuideng
- HACKING
- hongzhi
- hrichina
- HUANET
- hypermart.net
- incest
- jiangdongriji
- jiaochuang
- jiaochun
- KEFU
- KISSMYASS
- lihongzhi
- minghui
- minghuinews
- nacb
- Neckromancer
- NMIS
- PAPER64
- penis
- qiangjian
- renminbao
- renmingbao
- SHIT
- SUCKPENIS
- taip
- tibetalk
- triangle
- triangleboy
- Tringel
- UltraSurf
- ustibet
- voachinese
- wangce
- WEBZEN
- wstaiji
- xinsheng
- YUMING
- zangdu
- ZHENGJIAN
- ZHENGJIANWANG
- ZHENSHANREN
-
Loading…
Cancel
Save