diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/incoming_message.rb | 16 | ||||
-rw-r--r-- | app/models/public_body.rb | 8 | ||||
-rw-r--r-- | app/models/track_mailer.rb | 6 |
3 files changed, 12 insertions, 18 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 2b795ddf5..97e4a6c09 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -606,21 +606,13 @@ class IncomingMessage < ActiveRecord::Base text.gsub!(/^(>.*\n)/, replacement) text.gsub!(/^(On .+ (wrote|said):\n)/, replacement) - # Multiple line sections - # http://www.whatdotheyknow.com/request/identity_card_scheme_expenditure - # http://www.whatdotheyknow.com/request/parliament_protest_actions - # http://www.whatdotheyknow.com/request/64/response/102 - # http://www.whatdotheyknow.com/request/47/response/283 - # http://www.whatdotheyknow.com/request/30/response/166 - # http://www.whatdotheyknow.com/request/52/response/238 - # http://www.whatdotheyknow.com/request/224/response/328 # example with * * * * * - # http://www.whatdotheyknow.com/request/297/response/506 - ['-', '_', '*', '#'].each do |score| + ['-', '_', '*', '#'].each do |scorechar| + score = /(?:[#{scorechar}]\s*){8,}/ text.sub!(/(Disclaimer\s+)? # appears just before ( - \s*(?:[#{score}]\s*){8,}\s*\n.*? # top line + \s*#{score}\n(?:(?!#{score}\n).)*? # top line (disclaimer:\n|confidential|received\sthis\semail\sin\serror|virus|intended\s+recipient|monitored\s+centrally|intended\s+(for\s+|only\s+for\s+use\s+by\s+)the\s+addressee|routinely\s+monitored|MessageLabs|unauthorised\s+use) - .*?((?:[#{score}]\s*){8,}\s*\n|\z) # bottom line OR end of whole string (for ones with no terminator XXX risky) + .*?(?:#{score}|\z) # bottom line OR end of whole string (for ones with no terminator XXX risky) ) /imx, replacement) end diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 311e19001..ab836657b 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -378,7 +378,7 @@ class PublicBody < ActiveRecord::Base next if name.nil? name.strip! - email.strip! + email.strip! unless email.nil? if !email.nil? && !email.empty? && !MySociety::Validate.is_valid_email(email) errors.push "error: line #{line.to_s}: invalid email '#{email}' for authority '#{name}'" @@ -392,7 +392,7 @@ class PublicBody < ActiveRecord::Base PublicBody.with_locale(locale) do changed = {} field_list.each do |field_name| - localized_field_name = (locale === I18n.default_locale) ? field_name : "#{field_name}.#{locale}" + localized_field_name = (locale.to_s == I18n.default_locale.to_s) ? field_name : "#{field_name}.#{locale}" localized_value = field_names[localized_field_name] && row[field_names[localized_field_name]] # Tags are a special case, as we support adding to the field, not just setting a new value @@ -422,12 +422,12 @@ class PublicBody < ActiveRecord::Base end end else # New public body - public_body = PublicBody.new(:name=>name, :short_name=>"", :request_email=>"") + public_body = PublicBody.new(:name=>"", :short_name=>"", :request_email=>"") available_locales.each do |locale| PublicBody.with_locale(locale) do changed = {} field_list.each do |field_name| - localized_field_name = (locale === I18n.default_locale) ? field_name : "#{field_name}.#{locale}" + localized_field_name = (locale.to_s == I18n.default_locale.to_s) ? field_name : "#{field_name}.#{locale}" localized_value = field_names[localized_field_name] && row[field_names[localized_field_name]] if localized_field_name == 'tag_string' and tag_behaviour == 'add' diff --git a/app/models/track_mailer.rb b/app/models/track_mailer.rb index 85b1fedd8..0c053c4ad 100644 --- a/app/models/track_mailer.rb +++ b/app/models/track_mailer.rb @@ -40,10 +40,11 @@ class TrackMailer < ApplicationMailer # Useful query to run by hand to see how many alerts are due: # User.find(:all, :conditions => [ "last_daily_track_email < ?", Time.now - 1.day ]).size def self.alert_tracks + done_something = false now = Time.now() users = User.find(:all, :conditions => [ "last_daily_track_email < ?", now - 1.day ]) if users.empty? - return false + return done_something end for user in users next if !user.should_be_emailed? @@ -116,8 +117,9 @@ class TrackMailer < ApplicationMailer user.last_daily_track_email = now user.no_xapian_reindex = true user.save! + done_something = true end - return true + return done_something end def self.alert_tracks_loop |