Project

General

Profile

Patch #11684 ยป mailTruncate.patch

Joel Thompson, 2012-08-23 02:14

View differences:

app/models/mail_handler.rb
# Removes the email body of text after the truncation configurations.
def cleanup_body(body)
delimiters = Setting.mail_handler_body_delimiters.to_s.split(/[\r\n]+/).reject(&:blank?).map {|s| Regexp.escape(s)}
unless delimiters.empty?
regex = Regexp.new("^[> ]*(#{ delimiters.join('|') })\s*[\r\n].*", Regexp::MULTILINE)
body = body.gsub(regex, '')
address = Setting.mail_from
regex_arr = [
Regexp.new("From:\s*" + Regexp.escape(address), Regexp::IGNORECASE),
Regexp.new("<" + Regexp.escape(address) + ">", Regexp::IGNORECASE),
Regexp.new(Regexp.escape(address) + "\s+wrote:", Regexp::IGNORECASE),
Regexp.new("^.*On.*(\n)?wrote:$", Regexp::IGNORECASE),
Regexp.new("-+original\s+message-+\s*$", Regexp::IGNORECASE),
Regexp.new("from:\s*$", Regexp::IGNORECASE)
]
body_length = body.length
index = regex_arr.inject(body_length) do |min, regex|
[(body.index(regex) || body_length), min].min
end
body.strip
body[0, index].strip
end
def find_assignee_from_keyword(keyword, issue)
    (1-1/1)