aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Landauer <matthew@openaustralia.org>2012-10-11 07:45:01 +1100
committerMatthew Landauer <matthew@openaustralia.org>2012-10-11 07:45:01 +1100
commit84d9a8d6bebfa1dda24388a6267b6db4d54e41ef (patch)
tree69ff5af7f1400740cfbd446f629de76cb3f1536c
parent9319dc8b72b492e8f09624bc3974d4ea5c220104 (diff)
Extract method
-rw-r--r--app/models/exim_log.rb36
1 files changed, 21 insertions, 15 deletions
diff --git a/app/models/exim_log.rb b/app/models/exim_log.rb
index 4e50c1839..b6b35a8fc 100644
--- a/app/models/exim_log.rb
+++ b/app/models/exim_log.rb
@@ -125,6 +125,26 @@ class EximLog < ActiveRecord::Base
line.scan(/request-[^\s]+@#{Configuration::incoming_email_domain}/).sort.uniq
end
+ # Look at the log for a request and check that an email was delivered
+ def EximLog.request_sent?(ir)
+ # Look for line showing request was sent
+ found = false
+ for exim_log in ir.exim_logs
+ test_outgoing = " <= " + ir.incoming_email + " "
+ if exim_log.line.include?(test_outgoing)
+ # Check the from value is the same (it always will be, but may as well
+ # be sure we are parsing the exim line right)
+ envelope_from = " from <" + ir.incoming_email + "> "
+ if !exim_log.line.include?(envelope_from)
+ $stderr.puts("unexpected parsing of exim line: [#{exim_log.line.chomp}]")
+ else
+ found = true
+ end
+ end
+ end
+ found
+ end
+
# Check that the last day of requests has been sent in Exim and we got the
# lines. Writes any errors to STDERR. This check is really mainly to
# check the envelope from is the request address, as Ruby is quite
@@ -141,21 +161,7 @@ class EximLog < ActiveRecord::Base
# Go through each request and check it
ok = true
for ir in irs
- # Look for line showing request was sent
- found = false
- for exim_log in ir.exim_logs
- test_outgoing = " <= " + ir.incoming_email + " "
- if exim_log.line.include?(test_outgoing)
- # Check the from value is the same (it always will be, but may as well
- # be sure we are parsing the exim line right)
- envelope_from = " from <" + ir.incoming_email + "> "
- if !exim_log.line.include?(envelope_from)
- $stderr.puts("unexpected parsing of exim line: [#{exim_log.line.chomp}]")
- else
- found = true
- end
- end
- end
+ found = request_sent?(ir)
if !found
# It's very important the envelope from is set for avoiding spam filter reasons - this
# effectively acts as a check for that.