mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-07-16 23:18:56 +08:00
项目名称和描述增加敏感词检测
This commit is contained in:
@@ -138,6 +138,8 @@ class Project < ApplicationRecord
|
||||
delegate :content, to: :project_detail, allow_nil: true
|
||||
delegate :name, to: :license, prefix: true, allow_nil: true
|
||||
|
||||
validate :validate_sensitive_string
|
||||
|
||||
def self.all_visible(user_id=nil)
|
||||
user_projects_sql = Project.joins(:owner).where(users: {type: 'User'}).to_sql
|
||||
org_public_projects_sql = Project.joins(:owner).merge(Organization.joins(:organization_extension).where(organization_extensions: {visibility: 'common'})).to_sql
|
||||
@@ -409,4 +411,9 @@ class Project < ApplicationRecord
|
||||
def is_transfering
|
||||
applied_transfer_project&.common? ? true : false
|
||||
end
|
||||
|
||||
def validate_sensitive_string
|
||||
raise("项目名称包含敏感词汇,请重新输入") if name && !HarmoniousDictionary.clean?(name)
|
||||
raise("项目描述包含敏感词汇,请重新输入") if description && !HarmoniousDictionary.clean?(description)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user