aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Landauer <matthew@openaustralia.org>2012-10-10 13:51:41 +1100
committerMatthew Landauer <matthew@openaustralia.org>2012-10-10 13:51:41 +1100
commit6ea0e665066b7075e61f9e65ea109e6a2a468c4a (patch)
tree8ec9105e39eff87bd3a3d3f2049879827d62d2e6
parent089ce980170b1b2f96ed6b86c26e4d6e2069f39d (diff)
Extract method
-rw-r--r--app/models/exim_log.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/app/models/exim_log.rb b/app/models/exim_log.rb
index e7f4a4e8d..ef9afe317 100644
--- a/app/models/exim_log.rb
+++ b/app/models/exim_log.rb
@@ -61,8 +61,7 @@ class EximLog < ActiveRecord::Base
order = 0
f.each do |line|
order = order + 1
- email_domain = Configuration::incoming_email_domain
- emails = line.scan(/request-[^\s]+@#{email_domain}/).sort.uniq
+ emails = email_addresses_on_line(line)
for email in emails
info_request = InfoRequest.find_by_incoming_email(email)
if info_request
@@ -77,8 +76,7 @@ class EximLog < ActiveRecord::Base
def EximLog.scan_for_postfix_queue_ids(f)
result = {}
f.each do |line|
- email_domain = Configuration::incoming_email_domain
- emails = line.scan(/request-[^\s]+@#{email_domain}/).sort.uniq
+ emails = email_addresses_on_line(line)
# Assume the log file was written using syslog and parse accordingly
queue_id = SyslogProtocol.parse("<13>" + line).content.match(/^\S+: (\S+):/)[1]
result[queue_id] = [] unless result.has_key?(queue_id)
@@ -87,6 +85,10 @@ class EximLog < ActiveRecord::Base
result
end
+ def EximLog.email_addresses_on_line(line)
+ line.scan(/request-[^\s]+@#{Configuration::incoming_email_domain}/).sort.uniq
+ 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