mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-12 18:34:22 +01:00
change message gateway to save received email as attachment to the todo
This commit is contained in:
parent
8c17578f38
commit
d769f27e9e
2 changed files with 9 additions and 1 deletions
|
|
@ -18,7 +18,14 @@ class MessageGateway < ActionMailer::Base
|
|||
if saved
|
||||
Rails.logger.info "Saved email as todo for user #{user.login} in context #{context.name}"
|
||||
|
||||
saved = attach_email_to_todo(todo, email)
|
||||
attachment = todo.attachments.build
|
||||
tmp = Tempfile.new(['attachment', '.eml'], cr_newline: false)
|
||||
tmp.write email.raw_source.gsub(/\r\n?/, "\n") # replace \r with \n
|
||||
Rails.logger.info "Saved received email to #{tmp.path}"
|
||||
attachment.file = tmp
|
||||
tmp.close
|
||||
saved = attachment.save!
|
||||
tmp.unlink
|
||||
|
||||
if saved
|
||||
Rails.logger.info "Saved email as todo for user #{user.login} in context #{context.name}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue