mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-02 19:10:16 +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
|
if saved
|
||||||
Rails.logger.info "Saved email as todo for user #{user.login} in context #{context.name}"
|
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
|
if saved
|
||||||
Rails.logger.info "Saved email as todo for user #{user.login} in context #{context.name}"
|
Rails.logger.info "Saved email as todo for user #{user.login} in context #{context.name}"
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ Rails.application.routes.draw do
|
||||||
get 'convert_to_project' # TODO: convert to PUT/POST
|
get 'convert_to_project' # TODO: convert to PUT/POST
|
||||||
delete 'remove_predecessor' # TODO: convert to PUT/POST
|
delete 'remove_predecessor' # TODO: convert to PUT/POST
|
||||||
post 'change_context'
|
post 'change_context'
|
||||||
|
get 'attachment'
|
||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
get 'done'
|
get 'done'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue