aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/info_request.rb
diff options
context:
space:
mode:
authorMatthew Landauer <matthew@openaustralia.org>2013-03-29 11:15:29 +1100
committerMatthew Landauer <matthew@openaustralia.org>2013-03-29 11:15:29 +1100
commit3f306d3126e32cd64c2a691accd1af0a91c9aa48 (patch)
tree3e7adcbf6e6f0f1fa1f8a8938bcb5b4f6a91cb8b /app/models/info_request.rb
parentb6434d4b18e57e018bea6ab23916a0b134438b6a (diff)
Inline method and simplify logic
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r--app/models/info_request.rb23
1 files changed, 4 insertions, 19 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 156399b99..033bff036 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -351,7 +351,10 @@ public
# copying an email, and that doesn't matter)
def InfoRequest.find_by_incoming_email(incoming_email)
id, hash = InfoRequest._extract_id_hash_from_email(incoming_email)
- return self.find_by_magic_email(id, hash)
+ if hash_from_id(id) == hash
+ # Not using find(id) because we don't exception raised if nothing found
+ find_by_id(id)
+ end
end
# Return list of info requests which *might* be right given email address
@@ -902,24 +905,6 @@ public
return Digest::SHA1.hexdigest(id.to_s + AlaveteliConfiguration::incoming_email_secret)[0,8]
end
- # Called by find_by_incoming_email - and used to be called by separate
- # function for envelope from address, until we abandoned it.
- def InfoRequest.find_by_magic_email(id, hash)
- expected_hash = InfoRequest.hash_from_id(id)
- #print "expected: " + expected_hash + "\nhash: " + hash + "\n"
- if hash != expected_hash
- return nil
- else
- begin
- return self.find(id)
- rescue ActiveRecord::RecordNotFound
- # so error email is sent to admin, rather than the exception sending weird
- # error to the public body.
- return nil
- end
- end
- end
-
# Used to find when event last changed
def InfoRequest.last_event_time_clause(event_type=nil)
event_type_clause = ''