diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/info_request.rb | 4 | ||||
-rw-r--r-- | app/models/post_redirect.rb | 5 | ||||
-rw-r--r-- | app/models/request_mailer.rb | 16 |
3 files changed, 21 insertions, 4 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 72500d9e0..910519add 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -4,7 +4,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.14 2007-11-23 10:57:24 francis Exp $ +# $Id: info_request.rb,v 1.15 2007-11-23 12:01:20 francis Exp $ require 'digest/sha1' @@ -55,6 +55,8 @@ class InfoRequest < ActiveRecord::Base incoming_message.raw_data = raw_email incoming_message.info_request = self incoming_message.save + + RequestMailer.deliver_new_response(self, incoming_message) end # Work out what the situation of the request is diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb index a9f72c775..9ae5e337d 100644 --- a/app/models/post_redirect.rb +++ b/app/models/post_redirect.rb @@ -5,7 +5,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: post_redirect.rb,v 1.4 2007-11-06 15:58:56 francis Exp $ +# $Id: post_redirect.rb,v 1.5 2007-11-23 12:01:20 francis Exp $ require 'openssl' # for random bytes function @@ -18,6 +18,9 @@ class PostRedirect < ActiveRecord::Base self.post_params_yaml = params.to_yaml end def post_params + if self.post_params_yaml.nil? + return {} + end YAML.load(self.post_params_yaml) end diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index 4b691150d..683ff70fa 100644 --- a/app/models/request_mailer.rb +++ b/app/models/request_mailer.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: request_mailer.rb,v 1.6 2007-11-13 12:02:14 francis Exp $ +# $Id: request_mailer.rb,v 1.7 2007-11-23 12:01:20 francis Exp $ class RequestMailer < ActionMailer::Base @@ -26,6 +26,19 @@ class RequestMailer < ActionMailer::Base email.setup_forward(self) end + def new_response(info_request, incoming_message) + post_redirect = PostRedirect.new( + :uri => classify_request_url(:incoming_message_id => incoming_message.id), + :user_id => info_request.user.id) + post_redirect.save! + url = confirm_url(:email_token => post_redirect.email_token) + + @from = MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost') + @recipients = info_request.user.email + @subject = "New reponse to your FOI request - " + info_request.title + @body = { :incoming_message => incoming_message, :info_request => info_request, :url => url } + end + # Copy of function from action_mailer/base.rb, which passes the # raw_email to the member function, as we want to record it. # script/mailin calls this function. @@ -36,7 +49,6 @@ class RequestMailer < ActionMailer::Base new.receive(mail, raw_email) end - def receive(email, raw_email) # Find which info requests the email is for info_requests = [] |