diff options
-rw-r--r-- | app/models/outgoing_mailer.rb | 11 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 18 | ||||
-rw-r--r-- | app/views/admin_request/_incoming_message_actions.rhtml | 6 | ||||
m--------- | commonlib | 0 | ||||
-rw-r--r-- | config/.gitignore | 7 | ||||
-rw-r--r-- | config/general.yml-example | 64 | ||||
-rw-r--r-- | config/routes.rb | 2 | ||||
-rwxr-xr-x | script/rails-post-deploy | 2 |
8 files changed, 97 insertions, 13 deletions
diff --git a/app/models/outgoing_mailer.rb b/app/models/outgoing_mailer.rb index 1546d3fd0..bf81bb89f 100644 --- a/app/models/outgoing_mailer.rb +++ b/app/models/outgoing_mailer.rb @@ -22,6 +22,7 @@ class OutgoingMailer < ApplicationMailer @from = info_request.incoming_name_and_email @recipients = info_request.recipient_name_and_email @subject = info_request.email_subject_request + @headers["message-id"] = OutgoingMailer.id_for_message(outgoing_message) @body = {:info_request => info_request, :outgoing_message => outgoing_message, :contact_email => MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost') } end @@ -32,12 +33,12 @@ class OutgoingMailer < ApplicationMailer @from = info_request.incoming_name_and_email @recipients = OutgoingMailer.name_and_email_for_followup(info_request, incoming_message_followup) @subject = OutgoingMailer.subject_for_followup(info_request, outgoing_message) + @headers["message-id"] = OutgoingMailer.id_for_message(outgoing_message) @body = {:info_request => info_request, :outgoing_message => outgoing_message, :incoming_message_followup => incoming_message_followup, :contact_email => MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost') } end - # Separate function, so can be called from controller for logging # XXX the condition checking valid_to_reply_to? also appears in views/request/_followup.rhtml, # it shouldn't really, should call something here. # XXX also OutgoingMessage.get_salutation @@ -85,6 +86,14 @@ class OutgoingMailer < ApplicationMailer return true end end + # Message-ID to use + def OutgoingMailer.id_for_message(outgoing_message) + message_id = "ogm-" + outgoing_message.id.to_s + t = Time.now + message_id += "+" + '%08x%05x-%04x' % [t.to_i, t.tv_usec, rand(0xffff)] + message_id += "@" + MySociety::Config.get("INCOMING_EMAIL_DOMAIN", "localhost") + return "<" + message_id + ">" + end end diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index f9baad9b0..c7ba362e0 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -169,18 +169,28 @@ class OutgoingMessage < ActiveRecord::Base def send_message(log_event_type = 'sent') if self.status == 'ready' if self.message_type == 'initial_request' - OutgoingMailer.deliver_initial_request(self.info_request, self) self.last_sent_at = Time.now self.status = 'sent' self.save! - self.info_request.log_event(log_event_type, { :email => self.info_request.recipient_name_and_email, :outgoing_message_id => self.id }) + + mail_message = OutgoingMailer.deliver_initial_request(self.info_request, self) + self.info_request.log_event(log_event_type, { + :email => mail_message.to_addrs.join(", "), + :outgoing_message_id => self.id, + :smtp_message_id => mail_message.message_id + }) self.info_request.set_described_state('waiting_response') elsif self.message_type == 'followup' - OutgoingMailer.deliver_followup(self.info_request, self, self.incoming_message_followup) self.last_sent_at = Time.now self.status = 'sent' self.save! - self.info_request.log_event('followup_' + log_event_type, { :email => OutgoingMailer.name_and_email_for_followup(self.info_request, self.incoming_message_followup), :outgoing_message_id => self.id }) + + mail_message = OutgoingMailer.deliver_followup(self.info_request, self, self.incoming_message_followup) + self.info_request.log_event('followup_' + log_event_type, { + :email => mail_message.to_addrs.join(", "), + :outgoing_message_id => self.id, + :smtp_message_id => mail_message.message_id + }) if self.info_request.described_state == 'waiting_clarification' self.info_request.set_described_state('waiting_response') end diff --git a/app/views/admin_request/_incoming_message_actions.rhtml b/app/views/admin_request/_incoming_message_actions.rhtml index e31b4e97a..c23b4060a 100644 --- a/app/views/admin_request/_incoming_message_actions.rhtml +++ b/app/views/admin_request/_incoming_message_actions.rhtml @@ -1,7 +1,11 @@ <% form_tag '../redeliver_incoming' do %> <div> id or url_title of request: - <%= text_field_tag 'url_title', "", { :size => 20 } %> + <% if @info_requests && @info_requests.size == 1 %> + <%= text_field_tag 'url_title', @info_requests[0].url_title, { :size => 20 } %> + <% else %> + <%= text_field_tag 'url_title', "", { :size => 20 } %> + <% end %> <%= hidden_field_tag 'redeliver_incoming_message_id', incoming_message.id %> <%= submit_tag "Redeliver to another request" %> </div> diff --git a/commonlib b/commonlib -Subproject 38e0a641eb63323f6a2f895bfbc1274b23e98a7 +Subproject 6f3c48c96be88c3f20b15a1488bd35c00c2448f diff --git a/config/.gitignore b/config/.gitignore index b2ceae33c..28efb03ec 100644 --- a/config/.gitignore +++ b/config/.gitignore @@ -1,11 +1,8 @@ /config.tmp /general -/general.deployed +/general.yml /database.yml -/database.yml.deployed /rails_env.rb /logrotate -/logrotate.deployed /memcached.yml -/memcached.yml.deployed - +/*.deployed diff --git a/config/general.yml-example b/config/general.yml-example new file mode 100644 index 000000000..7d964360d --- /dev/null +++ b/config/general.yml-example @@ -0,0 +1,64 @@ +# general-example: +# Example values for the "general" config file. +# +# Configuration parameters, in PHP syntax. Configuration parameters are set +# using the PHP ...: '...') function. Both perl and PHP code +# parse this properly, so you can use comments and conditionals and whatnot, +# but unless essential it's better to keep it simple.... +# +# Copy this file to one called "general" in the same directory. Or +# have multiple config files and use a symlink to change between them. +# +# NOTE ON USE IN RAILS: By convention we always provide a default config value +# in the source code when reading the config option. The Rails application +# should run fine without the general config file: it is a bug if it does not. + +# Doesn't do anything right now. +STAGING_SITE: 1 + +# Domain used in URLs generated by scripts (e.g. for going in some emails) +DOMAIN: '127.0.0.1:3000' + +## Incoming email +# e.g. 'foifa.com' +INCOMING_EMAIL_DOMAIN: 'localhost' + +# e.g. 'foi+' +INCOMING_EMAIL_PREFIX: '' + +# used for hash in request email address +INCOMING_EMAIL_SECRET: 'xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx' + +# used as envelope from at the incoming email domain for cases where we don't care about failure +BLACKHOLE_PREFIX: 'do-not-reply-to-this-address' + +# Administration +CONTACT_EMAIL: 'admin@localhost' +ADMIN_BASE_URL: '/admin/' +# Where /stylesheets sits under for admin pages. See asset_host in +# config/environment.rb. Can be full domain or relative path (not an absolute path beginning with /). +ADMIN_PUBLIC_URL: '' + +# Secret key for signing cookie_store sessions +COOKIE_STORE_SESSION_SECRET: 'your secret key here, make it long and random' + +# If present, puts the site in read only mode, and uses the text as reason +# (whole paragraph). Please use a read-only database user as well, as it only +# checks in a few obvious places. +READ_ONLY: '' + +# Recaptcha, for detecting humans. Get keys here: http://recaptcha.net/whyrecaptcha.html +RECAPTCHA_PUBLIC_KEY: 'x' +RECAPTCHA_PRIVATE_KEY: 'x' + +# Locales we wish to support in this app +AVAILABLE_LOCALES: 'en es' + +# example searches for the home page, semicolon delimited +FRONTPAGE_SEARCH_EXAMPLES: 'Geraldine Quango; Department for Humpadinking' + +# example public bodies for the home page, semicolon delimited - short_names +FRONTPAGE_PUBLICBODY_EXAMPLES: 'tgq' + +# URL of theme to install +THEME_URL: 'git://github.com/mysociety/whatdotheyknow-theme.git' diff --git a/config/routes.rb b/config/routes.rb index a3ccb381e..ec0e24f67 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -163,7 +163,7 @@ ActionController::Routing::Routes.draw do |map| admin.admin_request_update_outgoing '/admin/request/update_outgoing/:id', :action => 'update_outgoing' admin.admin_request_edit_comment '/admin/request/edit_comment/:id', :action => 'edit_comment' admin.admin_request_update_comment '/admin/request/update_comment/:id', :action => 'update_comment' - admin.admin_request_destroy_incomine '/admin/request/destroy_incoming/:id', :action => 'destroy_incoming' + admin.admin_request_destroy_incoming '/admin/request/destroy_incoming/:id', :action => 'destroy_incoming' admin.admin_request_redeliver_incoming '/admin/request/redeliver_incoming', :action => 'redeliver_incoming' admin.admin_request_move_request '/admin/request/move_request', :action => 'move_request' admin.admin_request_generate_upload_url '/admin/request/generate_upload_url/:id', :action => 'generate_upload_url' diff --git a/script/rails-post-deploy b/script/rails-post-deploy index 1329d9973..1fe56212c 100755 --- a/script/rails-post-deploy +++ b/script/rails-post-deploy @@ -20,7 +20,7 @@ APP_DIR=`pwd` cd app/.. # read config file in for later (STAGING_SITE) -if [ -e "config/general" ] +if [ -e "config/general" ] || [ -e "config/general.yml" ] then . commonlib/shlib/deployfns read_conf config/general |