diff options
-rw-r--r-- | app/controllers/admin_request_controller.rb | 7 | ||||
-rw-r--r-- | app/models/contact_validator.rb | 4 | ||||
-rw-r--r-- | app/models/incoming_message.rb | 4 | ||||
-rw-r--r-- | app/models/info_request.rb | 12 | ||||
-rw-r--r-- | app/models/info_request_event.rb | 4 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 4 | ||||
-rw-r--r-- | app/models/post_redirect.rb | 4 | ||||
-rw-r--r-- | app/models/public_body.rb | 4 | ||||
-rw-r--r-- | app/models/public_body_tag.rb | 4 | ||||
-rw-r--r-- | app/models/request_mailer.rb | 14 | ||||
-rw-r--r-- | app/models/track_thing.rb | 4 | ||||
-rw-r--r-- | app/models/track_things_sent_email.rb | 4 | ||||
-rw-r--r-- | app/models/user.rb | 4 | ||||
-rw-r--r-- | app/models/user_info_request_sent_alert.rb | 4 | ||||
-rw-r--r-- | app/views/admin_request/edit.rhtml | 4 | ||||
-rw-r--r-- | app/views/request_mailer/stopped_responses.rhtml | 14 | ||||
-rw-r--r-- | db/migrate/055_stop_new_responses.rb | 9 | ||||
-rw-r--r-- | db/schema.rb | 3 | ||||
-rw-r--r-- | spec/fixtures/incoming-request-plain.email | 2 | ||||
-rw-r--r-- | spec/models/request_mailer_spec.rb | 23 | ||||
-rw-r--r-- | todo.txt | 24 |
21 files changed, 113 insertions, 43 deletions
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index f94861b5e..02481a9aa 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.12 2008-05-12 00:56:21 francis Exp $ +# $Id: admin_request_controller.rb,v 1.13 2008-05-19 12:01:21 francis Exp $ class AdminRequestController < ApplicationController layout "admin" @@ -43,6 +43,7 @@ class AdminRequestController < ApplicationController old_prominence = @info_request.prominence old_described_state = @info_request.described_state old_awaiting_description = @info_request.awaiting_description + old_stop_new_responses = @info_request.stop_new_responses @info_request.title = params[:info_request][:title] @info_request.prominence = params[:info_request][:prominence] @@ -50,6 +51,7 @@ class AdminRequestController < ApplicationController @info_request.set_described_state(params[:info_request][:described_state]) end @info_request.awaiting_description = params[:info_request][:awaiting_description] == "true" ? true : false + @info_request.stop_new_responses = params[:info_request][:stop_new_responses] == "true" ? true : false if @info_request.valid? @info_request.save! @@ -58,7 +60,8 @@ class AdminRequestController < ApplicationController :old_title => old_title, :title => @info_request.title, :old_prominence => old_prominence, :prominence => @info_request.prominence, :old_described_state => old_described_state, :described_state => @info_request.described_state, - :old_awaiting_description => old_awaiting_description, :awaiting_description => @info_request.awaiting_description + :old_awaiting_description => old_awaiting_description, :awaiting_description => @info_request.awaiting_description, + :old_stop_new_responses => old_stop_new_responses, :stop_new_responses => @info_request.stop_new_responses }) flash[:notice] = 'Request successfully updated.' redirect_to request_admin_url(@info_request) diff --git a/app/models/contact_validator.rb b/app/models/contact_validator.rb index 155219999..2738c9571 100644 --- a/app/models/contact_validator.rb +++ b/app/models/contact_validator.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 54 +# Schema version: 55 # # Table name: contact_validators # @@ -15,7 +15,7 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: contact_validator.rb,v 1.13 2008-05-12 01:38:18 francis Exp $ +# $Id: contact_validator.rb,v 1.14 2008-05-19 12:01:22 francis Exp $ class ContactValidator < ActiveRecord::BaseWithoutTable column :name, :string diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 43231761a..878997a11 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 54 +# Schema version: 55 # # Table name: incoming_messages # @@ -17,7 +17,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: incoming_message.rb,v 1.100 2008-05-12 23:07:31 francis Exp $ +# $Id: incoming_message.rb,v 1.101 2008-05-19 12:01:22 francis Exp $ # TODO # Move some of the (e.g. quoting) functions here into rblib, as they feel diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 64ed65a63..1f30c3cbb 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 54 +# Schema version: 55 # # Table name: info_requests # @@ -13,6 +13,7 @@ # awaiting_description :boolean default(false), not null # prominence :string(255) default("normal"), not null # url_title :text not null +# stop_new_responses :boolean default(false), not null # # models/info_request.rb: @@ -21,7 +22,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.111 2008-05-16 19:19:42 francis Exp $ +# $Id: info_request.rb,v 1.112 2008-05-19 12:01:22 francis Exp $ require 'digest/sha1' require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/lib/acts_as_xapian') @@ -164,6 +165,13 @@ public # A new incoming email to this request def receive(email, raw_email) + # See if new responses are prevented for spam reasons + if self.stop_new_responses + RequestMailer.deliver_stopped_responses(self, email) + return + end + + # Otherwise log the message incoming_message = IncomingMessage.new ActiveRecord::Base.transaction do diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index a692fec0d..b040f6320 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 54 +# Schema version: 55 # # Table name: info_request_events # @@ -20,7 +20,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: info_request_event.rb,v 1.43 2008-05-12 01:38:38 francis Exp $ +# $Id: info_request_event.rb,v 1.44 2008-05-19 12:01:22 francis Exp $ class InfoRequestEvent < ActiveRecord::Base belongs_to :info_request diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index 52d60dd8a..cf906a1a1 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 54 +# Schema version: 55 # # Table name: outgoing_messages # @@ -21,7 +21,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: outgoing_message.rb,v 1.48 2008-05-16 12:30:13 francis Exp $ +# $Id: outgoing_message.rb,v 1.49 2008-05-19 12:01:22 francis Exp $ class OutgoingMessage < ActiveRecord::Base belongs_to :info_request diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb index 9242ebf3f..5f732e36a 100644 --- a/app/models/post_redirect.rb +++ b/app/models/post_redirect.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 54 +# Schema version: 55 # # Table name: post_redirects # @@ -26,7 +26,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.31 2008-05-12 01:38:18 francis Exp $ +# $Id: post_redirect.rb,v 1.32 2008-05-19 12:01:22 francis Exp $ require 'openssl' # for random bytes function diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 376f3329e..e5f5cd667 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 54 +# Schema version: 55 # # Table name: public_bodies # @@ -21,7 +21,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: public_body.rb,v 1.69 2008-05-12 01:38:38 francis Exp $ +# $Id: public_body.rb,v 1.70 2008-05-19 12:01:22 francis Exp $ require 'csv' require 'set' diff --git a/app/models/public_body_tag.rb b/app/models/public_body_tag.rb index 0f4f164ee..2bad6778c 100644 --- a/app/models/public_body_tag.rb +++ b/app/models/public_body_tag.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 54 +# Schema version: 55 # # Table name: public_body_tags # @@ -15,7 +15,7 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: public_body_tag.rb,v 1.11 2008-05-12 01:38:18 francis Exp $ +# $Id: public_body_tag.rb,v 1.12 2008-05-19 12:01:22 francis Exp $ class PublicBodyTag < ActiveRecord::Base validates_presence_of :public_body diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index 09599b62e..cb43b59f8 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.31 2008-05-18 21:57:42 francis Exp $ +# $Id: request_mailer.rb,v 1.32 2008-05-19 12:01:22 francis Exp $ class RequestMailer < ApplicationMailer @@ -40,6 +40,18 @@ class RequestMailer < ApplicationMailer email.setup_forward(self) end + # Incoming message arrived for a request, but new responses have been stopped. + def stopped_responses(info_request, email) + @from = contact_from_name_and_email + @recipients = email.from_addrs.to_s + @subject = "Your response to an FOI request was not delivered" + email.setup_forward(self) + @body = { + :info_request => info_request, + :contact_email => MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost') + } + end + # An FOI response is outside the scope of the system, and needs admin attention def requires_admin(info_request) @from = contact_from_name_and_email diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index e5fa8f047..7fb72bff6 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 54 +# Schema version: 55 # # Table name: track_things # @@ -21,7 +21,7 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: track_thing.rb,v 1.21 2008-05-16 00:05:09 francis Exp $ +# $Id: track_thing.rb,v 1.22 2008-05-19 12:01:22 francis Exp $ class TrackThing < ActiveRecord::Base belongs_to :tracking_user, :class_name => 'User' diff --git a/app/models/track_things_sent_email.rb b/app/models/track_things_sent_email.rb index 4e6ce3001..eede4b5fc 100644 --- a/app/models/track_things_sent_email.rb +++ b/app/models/track_things_sent_email.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 54 +# Schema version: 55 # # Table name: track_things_sent_emails # @@ -18,7 +18,7 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: track_things_sent_email.rb,v 1.5 2008-05-16 01:14:12 francis Exp $ +# $Id: track_things_sent_email.rb,v 1.6 2008-05-19 12:01:22 francis Exp $ class TrackThingsSentEmail < ActiveRecord::Base belongs_to :info_request_event diff --git a/app/models/user.rb b/app/models/user.rb index b7727329d..ec34c8a6f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 54 +# Schema version: 55 # # Table name: users # @@ -21,7 +21,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: user.rb,v 1.54 2008-05-12 01:38:38 francis Exp $ +# $Id: user.rb,v 1.55 2008-05-19 12:01:22 francis Exp $ require 'digest/sha1' diff --git a/app/models/user_info_request_sent_alert.rb b/app/models/user_info_request_sent_alert.rb index 48e116d9a..7af7a599a 100644 --- a/app/models/user_info_request_sent_alert.rb +++ b/app/models/user_info_request_sent_alert.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 54 +# Schema version: 55 # # Table name: user_info_request_sent_alerts # @@ -17,7 +17,7 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: user_info_request_sent_alert.rb,v 1.13 2008-05-12 01:38:18 francis Exp $ +# $Id: user_info_request_sent_alert.rb,v 1.14 2008-05-19 12:01:22 francis Exp $ class UserInfoRequestSentAlert < ActiveRecord::Base belongs_to :user diff --git a/app/views/admin_request/edit.rhtml b/app/views/admin_request/edit.rhtml index e6d40337c..2d3745c1f 100644 --- a/app/views/admin_request/edit.rhtml +++ b/app/views/admin_request/edit.rhtml @@ -14,6 +14,10 @@ <%= select('info_request', "awaiting_description", [["Yes",true],["No",false]]) %> </p> + <p><label for="info_request_stop_new_responses">Stop new responses</label> (use this on requests getting spam, but also work out how the email leaked and plug it)<br/> + <%= select('info_request', "stop_new_responses", [["Yes",true],["No",false]]) %> + </p> + <p><label for="info_request_described_state">Described state</label><br/> <%= select( 'info_request', "described_state", [ diff --git a/app/views/request_mailer/stopped_responses.rhtml b/app/views/request_mailer/stopped_responses.rhtml new file mode 100644 index 000000000..43c6a2900 --- /dev/null +++ b/app/views/request_mailer/stopped_responses.rhtml @@ -0,0 +1,14 @@ +The email that you, on behalf of <%= @info_request.public_body.name%>, sent to +<%= @info_request.user.name %> to reply to a Freedom of Information request has +not been delivered. + +This is because '<%= @info_request.title %>' is an old request that has been +marked to no longer receive responses. + +If this is incorrect, or you would like to send a late response to the request +or an email on another subject to <%= @info_request.user.name %>, then please +email <%=@contact_email%> for help. + +Your original message is attached. + +-- the WhatDoTheyKnow team diff --git a/db/migrate/055_stop_new_responses.rb b/db/migrate/055_stop_new_responses.rb new file mode 100644 index 000000000..9c9e7ad9f --- /dev/null +++ b/db/migrate/055_stop_new_responses.rb @@ -0,0 +1,9 @@ +class StopNewResponses < ActiveRecord::Migration + def self.up + add_column :info_requests, :stop_new_responses, :boolean, :default => false, :null => false + end + + def self.down + remove :info_requests, :stop_new_responses + end +end diff --git a/db/schema.rb b/db/schema.rb index 254607810..4004371b8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 54) do +ActiveRecord::Schema.define(:version => 55) do create_table "acts_as_xapian_jobs", :force => true do |t| t.string "model", :null => false @@ -48,6 +48,7 @@ ActiveRecord::Schema.define(:version => 54) do t.boolean "awaiting_description", :default => false, :null => false t.string "prominence", :default => "normal", :null => false t.text "url_title", :null => false + t.boolean "stop_new_responses", :default => false, :null => false end add_index "info_requests", ["created_at"], :name => "index_info_requests_on_created_at" diff --git a/spec/fixtures/incoming-request-plain.email b/spec/fixtures/incoming-request-plain.email index ce1c7caa7..4ee258d2a 100644 --- a/spec/fixtures/incoming-request-plain.email +++ b/spec/fixtures/incoming-request-plain.email @@ -1,4 +1,4 @@ -From: Bob Smith <bob@localhost> +From: geraldinequango@localhost To: FOI Person <EMAIL_TO> Bcc: Subject: Re: Freedom of Information Request - Why aren't you leaving the house? diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb index 8c7eaefe2..98c27cca9 100644 --- a/spec/models/request_mailer_spec.rb +++ b/spec/models/request_mailer_spec.rb @@ -21,11 +21,32 @@ describe RequestMailer, " when receiving incoming mail" do ir.incoming_messages.size.should == 1 deliveries = ActionMailer::Base.deliveries - deliveries.size.should == 1 + deliveries.size.should == 1 mail = deliveries[0] mail.to.should == [ MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost') ] + deliveries.clear end + it "should return incoming mail to sender when a request is stopped for spam" do + # mark request as anti-spam + ir = info_requests(:fancy_dog_request) + ir.stop_new_responses = true + ir.save! + + # test what happens if something arrives + ir.incoming_messages.size.should == 1 # in the fixture + receive_incoming_mail('incoming-request-plain.email', ir.incoming_email) + ir.incoming_messages.size.should == 1 # nothing should arrive + + # should be a message back to sender + deliveries = ActionMailer::Base.deliveries + deliveries.size.should == 1 + mail = deliveries[0] + mail.to.should == [ 'geraldinequango@localhost' ] + deliveries.clear + end + + it "should not mutilate long URLs when trying to word wrap them" do long_url = 'http://www.this.is.quite.a.long.url.flourish.org/there.is.no.way.it.is.short.whatsoever' body = "This is a message with quite a long URL in it. It also has a paragraph, being this one that has quite a lot of text in it to. Enough to test the wrapping of itself. @@ -31,6 +31,9 @@ BAILII - relationship with law courts, robots.txt ? Next ==== +Block new messages to particular requests (for those we failed to spam protect +in time) + Blog posts / Wikipedia articles about this request e.g. http://socialreporter.wordpress.com/2008/04/14/costs-of-the-bbc-action-action-network/ http://reportr.net/2008/04/24/bbc-spent-6m-to-develop-the-iplayer/ @@ -40,6 +43,8 @@ Check test code coverage again - do we have all models Reconsider described vs. newest sort order for the RSS for each track separately +Bit confusing that sort order when you do "variety:successful" in query is by the date of creation. +Should probably use the described date a lot more often for dates. But not sure, hard to tell. Fix up the privacy policy @@ -49,16 +54,13 @@ Advertise alerts on end pages with WDTK Later ===== +Show people tracking same query, when you are on search page + Display current page (when not on first page), or perhaps range on both the /list pages, and on the /..../similar pages (maybe I missed it elsewhere too). Should make a general will_paginate like function to do this part, and call that from /search (which has this already) too. -Bit confusing that sort order when you do "variety:successful" in query is by the date of creation. -Should probably use the described date a lot more often for dates. But not sure, hard to tell. - -HTML in Atom feed ask Tommy about it - Check this again after a while, for dodgy states of events: s = InfoRequest.find(:all).select { |i| (not i.awaiting_description) and i.get_last_response_event_id and InfoRequestEvent.find(i.get_last_response_event_id).calculated_state != i.described_state }; s.size @@ -67,7 +69,7 @@ Museum aliases Highlight text search finds in word docs Edits to outgoing/incoming/title won't be reindexed in Xapian (maybe just reindex all once a week) -Make highlighting of search terms in RSS actually light up +Make highlighting of search terms in RSS actually light up (maybe ask Tommy) Put name of admin user rather than import_csv @@ -111,9 +113,6 @@ last event which resets the due date Overdue response alert email click through should show how many days overdue it is near where you write your reply -Remove staging site stuff, and making the banner a not www.whatdotheyknow.com -banner - Synthesise these tips into our handful of snappy snappy bullet points http://community.foe.co.uk/tools/right_to_know/tips.html http://www.justice.gov.uk/requestinginformation.htm @@ -124,9 +123,6 @@ Show public body email address on their public page, with a link to say "this is CSV export of lists of emails for admins -Requests with related content - - via a compare document search somehow? - - using the tracking requests network Show list of popular tracks somewhere (finds most popular requests in a way) Remember me box @@ -197,7 +193,7 @@ Show documents inline (word docs etc.) Julian's PDF excerpting thing for highlighting paragraphs and convert Word Docs to PDFs too -Remove request email address from PDFs +Remove request email address from PDFs (we already do from docs) http://www.whatdotheyknow.com/request/cost_of_policing_the_oxford_unio_3 - maybe if text contains email, refuse to show full PDF just show conversion to text/HTML? @@ -226,6 +222,8 @@ Quoting fixing TODO: http://www.whatdotheyknow.com/request/320/response/605 (encoding, vcf) http://www.whatdotheyknow.com/request/118/response/600 (encoding) http://www.whatdotheyknow.com/request/235/response/513 + http://www.whatdotheyknow.com/request/40/response/163 - Disclaimer + http://www.whatdotheyknow.com/request/265/response/688 - word wrapping Sources of public bodies ======================== |