diff options
author | Matthew Landauer <matthew@openaustralia.org> | 2012-10-10 14:20:30 +1100 |
---|---|---|
committer | Matthew Landauer <matthew@openaustralia.org> | 2012-10-10 14:20:30 +1100 |
commit | 227f04b9393d9258e7013afce9ceb01a653a841c (patch) | |
tree | 09d6989c70fe81791094f984e3803b978413864d /app/models | |
parent | 79c26d3b5fa7d77ca22f77b6c70d42212bd7a578 (diff) |
Add method for loading postfix log data
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/exim_log.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/models/exim_log.rb b/app/models/exim_log.rb index cbe2277c5..4c3e104af 100644 --- a/app/models/exim_log.rb +++ b/app/models/exim_log.rb @@ -73,6 +73,27 @@ class EximLog < ActiveRecord::Base end end + def EximLog.load_postfix_log_data(f, done) + order = 0 + emails = scan_for_postfix_queue_ids(f) + # Go back to the beginning of the file + f.rewind + f.each do |line| + order = order + 1 + queue_id = extract_queue_id_from_syslog_line(line) + if emails.has_key?(queue_id) + emails[queue_id].each do |email| + info_request = InfoRequest.find_by_incoming_email(email) + if info_request + info_request.exim_logs.create!(:line => line, :order => order, :exim_log_done => done) + else + puts "Warning: Could not find request with email #{email}" + end + end + end + end + end + def EximLog.scan_for_postfix_queue_ids(f) result = {} f.each do |line| |