Mercurial > hg > soundsoftware-site
comparison app/models/mail_handler.rb @ 1517:dffacf8a6908 redmine-2.5
Update to Redmine SVN revision 13367 on 2.5-stable branch
author | Chris Cannam |
---|---|
date | Tue, 09 Sep 2014 09:29:00 +0100 |
parents | e248c7af89ec |
children | fb9a13467253 |
comparison
equal
deleted
inserted
replaced
1516:b450a9d58aed | 1517:dffacf8a6908 |
---|---|
188 issue.subject = cleaned_up_subject | 188 issue.subject = cleaned_up_subject |
189 if issue.subject.blank? | 189 if issue.subject.blank? |
190 issue.subject = '(no subject)' | 190 issue.subject = '(no subject)' |
191 end | 191 end |
192 issue.description = cleaned_up_text_body | 192 issue.description = cleaned_up_text_body |
193 issue.start_date ||= Date.today if Setting.default_issue_start_date_to_creation_date? | |
193 | 194 |
194 # add To and Cc as watchers before saving so the watchers can reply to Redmine | 195 # add To and Cc as watchers before saving so the watchers can reply to Redmine |
195 add_watchers(issue) | 196 add_watchers(issue) |
196 issue.save! | 197 issue.save! |
197 add_attachments(issue) | 198 add_attachments(issue) |
294 # appropriate permission | 295 # appropriate permission |
295 def add_watchers(obj) | 296 def add_watchers(obj) |
296 if user.allowed_to?("add_#{obj.class.name.underscore}_watchers".to_sym, obj.project) | 297 if user.allowed_to?("add_#{obj.class.name.underscore}_watchers".to_sym, obj.project) |
297 addresses = [email.to, email.cc].flatten.compact.uniq.collect {|a| a.strip.downcase} | 298 addresses = [email.to, email.cc].flatten.compact.uniq.collect {|a| a.strip.downcase} |
298 unless addresses.empty? | 299 unless addresses.empty? |
299 watchers = User.active.where('LOWER(mail) IN (?)', addresses).all | 300 User.active.where('LOWER(mail) IN (?)', addresses).each do |w| |
300 watchers.each {|w| obj.add_watcher(w)} | 301 obj.add_watcher(w) |
302 end | |
301 end | 303 end |
302 end | 304 end |
303 end | 305 end |
304 | 306 |
305 def get_keyword(attr, options={}) | 307 def get_keyword(attr, options={}) |
408 | 410 |
409 parts.reject! do |part| | 411 parts.reject! do |part| |
410 part.header[:content_disposition].try(:disposition_type) == 'attachment' | 412 part.header[:content_disposition].try(:disposition_type) == 'attachment' |
411 end | 413 end |
412 | 414 |
413 @plain_text_body = parts.map {|p| Redmine::CodesetUtil.to_utf8(p.body.decoded, p.charset)}.join("\r\n") | 415 @plain_text_body = parts.map do |p| |
416 body_charset = p.charset.respond_to?(:force_encoding) ? | |
417 Mail::RubyVer.pick_encoding(p.charset).to_s : p.charset | |
418 Redmine::CodesetUtil.to_utf8(p.body.decoded, body_charset) | |
419 end.join("\r\n") | |
414 | 420 |
415 # strip html tags and remove doctype directive | 421 # strip html tags and remove doctype directive |
416 if parts.any? {|p| p.mime_type == 'text/html'} | 422 if parts.any? {|p| p.mime_type == 'text/html'} |
417 @plain_text_body = strip_tags(@plain_text_body.strip) | 423 @plain_text_body = strip_tags(@plain_text_body.strip) |
418 @plain_text_body.sub! %r{^<!DOCTYPE .*$}, '' | 424 @plain_text_body.sub! %r{^<!DOCTYPE .*$}, '' |