From 402300c848f9500f9a86c56ed0f7555d41c83ccb Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 30 Jan 2018 15:05:52 +0100 Subject: [PATCH] Added helper method to process unprocessable mails again (Channel::EmailParser.process_unprocessable_mails). --- app/models/channel/email_parser.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index 0f858c353..f241de3d2 100644 --- a/app/models/channel/email_parser.rb +++ b/app/models/channel/email_parser.rb @@ -825,6 +825,26 @@ returns end end +=begin + +process unprocessable_mails (tmp/unprocessable_mail/*.eml) again + + Channel::EmailParser.process_unprocessable_mails + +=end + + def self.process_unprocessable_mails(params = {}) + path = Rails.root.join('tmp', 'unprocessable_mail') + files = [] + Dir.glob("#{path}/*.eml") do |entry| + ticket, article, user, mail = Channel::EmailParser.new.process(params, IO.binread(entry)) + next if ticket.blank? + files.push entry + File.delete(entry) + end + files + end + end module Mail