diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb index 0696216..079181d 100644 --- a/app/models/mail_handler.rb +++ b/app/models/mail_handler.rb @@ -212,8 +212,8 @@ class MailHandler < ActionMailer::Base # add To and Cc as watchers before saving so the watchers can reply to Redmine add_watchers(issue) - issue.save! add_attachments(issue) + issue.save! logger.info "MailHandler: issue ##{issue.id} created by #{user}" if logger issue end @@ -287,7 +287,7 @@ class MailHandler < ActionMailer::Base if email.attachments && email.attachments.any? email.attachments.each do |attachment| next unless accept_attachment?(attachment) - obj.attachments << Attachment.create(:container => obj, + obj.attachments << Attachment.create( :file => attachment.decoded, :filename => attachment.filename, :author => user, diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 4bfa45b..1fd4473 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -48,6 +48,13 @@ class Mailer < ActionMailer::Base @issue = issue @users = to_users + cc_users @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue) + + unless Setting.plain_text_mail? + issue.attachments.each do |attachment| + attachments[attachment.filename] = File.read(attachment.diskfile) + end + end + mail :to => to_users, :cc => cc_users, :subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}" @@ -80,6 +87,15 @@ class Mailer < ActionMailer::Base @journal = journal @journal_details = journal.visible_details(@users.first) @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}") + + unless Setting.plain_text_mail? + journal.details.each do |detail| + if detail.property == 'attachment' && attachment = Attachment.find_by_id(detail.prop_key) + attachments[attachment.filename] = File.read(attachment.diskfile) + end + end + end + mail :to => to_users, :cc => cc_users, :subject => s