aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/exim_log.rb10
-rw-r--r--config/general.yml-example3
-rw-r--r--lib/configuration.rb1
-rw-r--r--spec/models/exim_log_spec.rb1
4 files changed, 5 insertions, 10 deletions
diff --git a/app/models/exim_log.rb b/app/models/exim_log.rb
index e3be1805f..4e50c1839 100644
--- a/app/models/exim_log.rb
+++ b/app/models/exim_log.rb
@@ -54,8 +54,7 @@ class EximLog < ActiveRecord::Base
done.save!
f = is_gz ? Zlib::GzipReader.open(file_name) : File.open(file_name, 'r')
- type = detect_mta_log_type(f)
- case(type)
+ case(Configuration::mta_log_type.to_sym)
when :exim
load_exim_log_data(f, done)
when :postfix
@@ -66,13 +65,6 @@ class EximLog < ActiveRecord::Base
end
end
- # Unbelievably dumb heuristic for detecting whether this is an exim or a postfix log
- def EximLog.detect_mta_log_type(f)
- r = (f.readline =~ /postfix/) ? :postfix : :exim
- f.rewind
- r
- end
-
# Scan the file
def EximLog.load_exim_log_data(f, done)
order = 0
diff --git a/config/general.yml-example b/config/general.yml-example
index 6f121190d..8f14fa88a 100644
--- a/config/general.yml-example
+++ b/config/general.yml-example
@@ -175,3 +175,6 @@ UTILITY_SEARCH_PATH: ["/usr/bin", "/usr/local/bin"]
# Path to your exim or postfix log files that will get sucked up by script/load-exim-logs
MTA_LOG_PATH: '/var/log/exim4/exim-mainlog-*'
+
+# Whether we are using "exim" or "postfix" for our MTA
+MTA_LOG_TYPE: "exim"
diff --git a/lib/configuration.rb b/lib/configuration.rb
index 5f761a1f6..ee2ce40c5 100644
--- a/lib/configuration.rb
+++ b/lib/configuration.rb
@@ -30,6 +30,7 @@ module Configuration
:INCOMING_EMAIL_SECRET => 'dummysecret',
:ISO_COUNTRY_CODE => 'GB',
:MAX_REQUESTS_PER_USER_PER_DAY => nil,
+ :MTA_LOG_TYPE => 'exim',
:NEW_RESPONSE_REMINDER_AFTER_DAYS => [3, 10, 24],
:OVERRIDE_ALL_PUBLIC_BODY_REQUEST_EMAILS => '',
:RAW_EMAILS_LOCATION => 'files/raw_emails',
diff --git a/spec/models/exim_log_spec.rb b/spec/models/exim_log_spec.rb
index b9826be72..87aa6d610 100644
--- a/spec/models/exim_log_spec.rb
+++ b/spec/models/exim_log_spec.rb
@@ -5,7 +5,6 @@ describe EximLog do
before :each do
Configuration.stub!(:incoming_email_domain).and_return("example.com")
File.stub_chain(:stat, :mtime).and_return(DateTime.new(2012, 10, 10))
- EximLog.stub!(:detect_mta_log_type).and_return(:exim)
end
let(:log) {[