Project

General

Profile

Feature #3050 » fix-receiving-new-issues-with-attachments.patch

Alex Shulgin, 2011-08-09 10:24

View differences:

app/models/issue.rb
end
def attachment_added(obj)
init_journal(User.current) unless @current_journal
@current_journal.details << JournalDetail.new(:property => 'attachment',
:prop_key => obj.id,
:value => obj.filename)
end
def attachment_removed(obj)
journal = init_journal(User.current)
journal.details << JournalDetail.new(:property => 'attachment',
:prop_key => obj.id,
:old_value => obj.filename)
journal.save
init_journal(User.current) unless @current_journal
@current_journal.details << JournalDetail.new(:property => 'attachment',
:prop_key => obj.id,
:old_value => obj.filename)
# Currently, this is only triggered from attachments#destroy, so
# there's no one else to save the issue's journal.
@current_journal.save
end
# Default assignment based on category
app/models/mail_handler.rb
# add To and Cc as watchers before saving so the watchers can reply to Redmine
add_watchers(issue)
issue.save!
add_attachments(issue)
if add_attachments(issue)
# Adding attachments to a new issue creates a journal. We need
# to save the record to trigger an issue update mail.
issue.save!
end
logger.info "MailHandler: issue ##{issue.id} created by #{user}" if logger && logger.info
issue
end
......
end
def add_attachments(obj)
added = false
if email.has_attachments? || email.multipart?
email.attachments.each do |attachment|
obj.attachments.create(:file => attachment,
:author => user,
:content_type => attachment.content_type)
added = true
end
end
added
end
# Adds To and Cc as watchers of the given object if the sender has the
(2-2/2)