diff options
-rw-r--r-- | app/controllers/admin_request_controller.rb | 13 | ||||
-rw-r--r-- | app/models/info_request.rb | 22 | ||||
-rw-r--r-- | app/views/admin_request/show_raw_email.rhtml | 18 | ||||
-rw-r--r-- | todo.txt | 45 |
4 files changed, 66 insertions, 32 deletions
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index d0bf9cd48..b8b9fb56a 100644 --- a/app/controllers/admin_request_controller.rb +++ b/app/controllers/admin_request_controller.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: admin_request_controller.rb,v 1.38 2009-07-21 12:09:29 francis Exp $ +# $Id: admin_request_controller.rb,v 1.39 2009-09-07 16:35:05 francis Exp $ class AdminRequestController < AdminController def index @@ -228,12 +228,13 @@ class AdminRequestController < AdminController def show_raw_email @raw_email = RawEmail.find(params[:id]) - # For the holding pen, use domain of email to try and guess which public body it - # is associated with, so we can display that. + # For the holding pen, try to guess where it should be ... @holding_pen = false if (@raw_email.incoming_message.info_request == InfoRequest.holding_pen_request && @raw_email.incoming_message.mail.from_addrs.size > 0) @holding_pen = true + # 1. Use domain of email to try and guess which public body it + # is associated with, so we can display that. email = @raw_email.incoming_message.mail.from_addrs[0].spec domain = PublicBody.extract_domain_from_email(email) @@ -243,6 +244,12 @@ class AdminRequestController < AdminController @public_bodies = PublicBody.find(:all, :order => "name", :conditions => [ "lower(request_email) like lower('%'||?||'%')", domain ]) end + + # 2. Match the email address in the message without matching the hash + @info_requests = [] + for address in (@raw_email.incoming_message.mail.to || []) + (@raw_email.incoming_message.mail.cc || []) + @info_requests += InfoRequest.guess_by_incoming_email(address) + end end end diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 1969d1947..da5270c40 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.201 2009-08-21 17:43:33 francis Exp $ +# $Id: info_request.rb,v 1.202 2009-09-07 16:35:06 francis Exp $ require 'digest/sha1' require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/lib/acts_as_xapian') @@ -246,6 +246,23 @@ public # the prefix and domain, as sometimes those change, or might be elided by # 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) + end + + # Return list of info requests which *might* be right given email address + # e.g. For the id-hash email addresses, don't match the hash. + def InfoRequest.guess_by_incoming_email(incoming_email) + id, hash = InfoRequest._extract_id_hash_from_email(incoming_email) + begin + return [InfoRequest.find(id)] + rescue ActiveRecord::RecordNotFound + return [] + end + end + + # Internal function used by find_by_magic_email and guess_by_incoming_email + def InfoRequest._extract_id_hash_from_email(incoming_email) # Match case insensitively, FOI officers often write Request with capital R. incoming_email = incoming_email.downcase @@ -263,9 +280,10 @@ public hash.gsub!(/o/, "0") end - return self.find_by_magic_email(id, hash) + return [id, hash] end + # When constructing a new request, use this to check user hasn't double submitted. # XXX could have a date range here, so say only check last month's worth of new requests. If somebody is making # repeated requests, say once a quarter for time information, then might need to do that. diff --git a/app/views/admin_request/show_raw_email.rhtml b/app/views/admin_request/show_raw_email.rhtml index fa2a4f9e6..10b97f4fd 100644 --- a/app/views/admin_request/show_raw_email.rhtml +++ b/app/views/admin_request/show_raw_email.rhtml @@ -4,10 +4,20 @@ <p> FOI request: <%= link_to request_both_links(@raw_email.incoming_message.info_request) %> - <% if @holding_pen && @public_bodies.size > 0 %> - <br>Guessed authority: - <% for public_body in @public_bodies %> - <%=public_body_both_links(public_body)%> + <% if @holding_pen %> + <% if @public_bodies.size > 0 %> + <br>Guessed authority: + <% for public_body in @public_bodies %> + <%=public_body_both_links(public_body)%> + <% end %> + (based on From: email domain) + <% end %> + <% if @info_requests.size > 0 %> + <br>Guessed request: + <% for info_request in @info_requests %> + <%=request_both_links(info_request)%> + <% end %> + (based on id, not hash, in To/Cc email) <% end %> <% end %> </p> @@ -1,36 +1,30 @@ -Next (things that will reduce admin time mainly) -==== - -holding_pen - detect ones with just bad checksum +Make incoming mail script tell exim to hold messages and try redelivery when + it goes wrong +And email admins Things to make bots not crawl: /request/13683/response?internal_review=1 /request/febrile_neutropenia_154?unfold=1 + /list/recent?page=671 -Cache some common pages, such as "view requests": - http://www.whatdotheyknow.com/list/successful -And all individual requests. - -/request/13683/response?internal_review=1 +Next (things that will reduce admin time mainly) +==== Factor out "defunct/not_apply" from request_email into own field so defunct authorities can still have followups to existing requests. Probably into tags. -Add help about not adding extraneous or possibly libelous content to -requests or followups. Explain how to write things to avoid libel law. -Perhaps use these house rules: +Have proper house rules / site terms and conditions page. +Perhaps borrow from these house rules: http://www.theyworkforyou.com/houserules/ -Button for people to say "this status is really quite wrong please -fix it"? - Lots of authorities are starting to complain about how their record looks on their page - e.g responses not classified by users. That users may classify incorrectly. Change wording to make it clear statuses are users opinion ?. * Meanwhile mention in help that authorities can do this * And ask that they include URL of requests in emails when talking about them +Finish up the request game, and market it a bit more. Check up on how the public old request status editing is being used in practice. Think about UI a bit more to try and up rate, and UI of alerts to requester. @@ -42,10 +36,14 @@ valid reason for delay. Allow for deadline extension for schools. -Put the request from address in the database, then change the rule for making it. +Put the request from address in the database, + XXX not so sure about that, as need fuzzy rule for matching/guessing according to type +then change the rule for making it. * Use maybe words for generated email address? Name of the person and a request number (i.e. number of that persons request, so there are few numbers)? julian.todd@section44.whatdotheyknow.com +* Use words from a dictionary, e.g. cat, mouse, rat, hat etc. +* Use single words from the request, e.g. section, terrorism, allotment * Make sure avoid FROM_ENDS_IN_NUMS rule in Spam Assassin * Identify authority by who it is from. * It looks like an error generated by GFI MailEssentials, see p62 of chapter @@ -63,8 +61,7 @@ Julian things: Use FOI code from them authority to work out where emails are to go Keep FOI code in subject to help them a bit Show requests by authority on user page - Let the user refile ones that have arrived in wrong place - Second request by same person - tell them to use this email + Second request to same authority by same person - tell them to use this email check-recent-requests-sent probably doesn't work, as exim log lines wouldn't be load in case where the envelope from gets broken? @@ -73,19 +70,21 @@ Admin button to resend request one off to particular address Add explicit option for user to select "misdelivered to the wrong request" and let people move them to the right place. +(Julian wants that too) Give authorities interface for editing their request email address and resend messages to them -Page cacheing - the cookie setting stops the expires_on caching working well, -as even when not logged in second page you go to isnt serverd from Squid cache. -Maybe change to fragment caching for things like the "view requests" page? -Then will help logged in users too. - Later ===== +Renaming of a body, or changing its domain, should clear the cached bubbles of +all requests to that body. + +Page cacheing - the cookie setting stops the expires_on caching working well, +as even when not logged in second page you go to isnt serverd from Squid cache. + Emails sent to stopped requests should follow RFC: http://tools.ietf.org/html/rfc3834 Shouldn't bounce message back to Auto-Submitted Should check from address being replied to is valid |