mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
DEV: Improve mbox import script
* Better documentation of settings * Add option to exclude trimmed parts of emails (enabled by default) to not revail email addresses
This commit is contained in:
@ -19,6 +19,7 @@ module ImportScripts::Mbox
|
||||
attr_reader :group_messages_by_subject
|
||||
attr_reader :subject_prefix_regex
|
||||
attr_reader :automatically_remove_list_name_prefix
|
||||
attr_reader :show_trimmed_content
|
||||
attr_reader :tags
|
||||
|
||||
def initialize(yaml)
|
||||
@ -31,20 +32,23 @@ module ImportScripts::Mbox
|
||||
@index_only = yaml['index_only']
|
||||
@group_messages_by_subject = yaml['group_messages_by_subject']
|
||||
|
||||
unless yaml['remove_subject_prefixes'].empty?
|
||||
if yaml['remove_subject_prefixes'].present?
|
||||
prefix_regexes = yaml['remove_subject_prefixes'].map { |p| Regexp.new(p) }
|
||||
@subject_prefix_regex = /^#{Regexp.union(prefix_regexes).source}/i
|
||||
end
|
||||
|
||||
@automatically_remove_list_name_prefix = yaml['automatically_remove_list_name_prefix']
|
||||
@show_trimmed_content = yaml['show_trimmed_content']
|
||||
|
||||
@tags = []
|
||||
yaml['tags'].each do |tag_name, value|
|
||||
prefixes = Regexp.union(value).source
|
||||
@tags << {
|
||||
regex: /^(?:(?:\[(?:#{prefixes})\])|(?:\((?:#{prefixes})\)))\s*/i,
|
||||
name: tag_name
|
||||
}
|
||||
if yaml['tags'].present?
|
||||
@tags = []
|
||||
yaml['tags'].each do |tag_name, value|
|
||||
prefixes = Regexp.union(value).source
|
||||
@tags << {
|
||||
regex: /^(?:(?:\[(?:#{prefixes})\])|(?:\((?:#{prefixes})\)))\s*/i,
|
||||
name: tag_name
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user