From a17137c4a545ad8b5d7c073c98ad5d43cc80f181 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 29 Jan 2019 21:35:22 +0100 Subject: [PATCH] Improved email processing - added error/timeout handling. --- app/models/channel/email_parser.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index 5d39ab21e..a3b34f9a4 100644 --- a/app/models/channel/email_parser.rb +++ b/app/models/channel/email_parser.rb @@ -3,6 +3,7 @@ # encoding: utf-8 class Channel::EmailParser + PROZESS_TIME_MAX = 180 EMAIL_REGEX = /.+@.+/.freeze RECIPIENT_FIELDS = %w[to cc delivered-to x-original-to envelope-to].freeze SENDER_FIELDS = %w[from reply-to return-path sender].freeze @@ -106,7 +107,9 @@ returns def process(channel, msg, exception = true) - _process(channel, msg) + Timeout.timeout(PROZESS_TIME_MAX) do + _process(channel, msg) + end rescue => e # store unprocessable email for bug reporting path = Rails.root.join('tmp', 'unprocessable_mail')