aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/info_request.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r--app/models/info_request.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index dfa66102e..13d5c8a2e 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -24,7 +24,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: info_request.rb,v 1.198 2009-07-03 11:43:37 francis Exp $
+# $Id: info_request.rb,v 1.199 2009-08-18 20:51:26 francis Exp $
require 'digest/sha1'
require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/lib/acts_as_xapian')
@@ -279,6 +279,17 @@ public
end
end
+ def find_existing_outgoing_message(body)
+ # XXX can add other databases here which have regexp_replace
+ if ActiveRecord::Base.connection.adapter_name == "PostgreSQL"
+ # Exclude spaces from the body comparison using regexp_replace
+ return self.outgoing_messages.find(:first, :conditions => [ "regexp_replace(outgoing_messages.body, '[[:space:]]', '', 'g') = regexp_replace(?, '[[:space:]]', '', 'g')", body ])
+ else
+ # For other databases (e.g. SQLite) not the end of the world being space-sensitive for this check
+ return self.outgoing_messages.find(:first, :conditions => [ "outgoing_messages.body = ?", body ])
+ end
+ end
+
# A new incoming email to this request
def receive(email, raw_email_data, override_stop_new_responses = false)
if !override_stop_new_responses