aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin_request_controller.rb6
-rw-r--r--app/controllers/general_controller.rb6
-rw-r--r--app/models/incoming_message.rb32
-rw-r--r--app/models/info_request.rb16
-rw-r--r--app/models/outgoing_mailer.rb4
-rw-r--r--app/views/comment/_single_comment.rhtml2
-rw-r--r--app/views/request/_correspondence.rhtml24
-rw-r--r--app/views/user/_show_user_info.rhtml2
8 files changed, 53 insertions, 39 deletions
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb
index 3e574b10f..6b6a8525e 100644
--- a/app/controllers/admin_request_controller.rb
+++ b/app/controllers/admin_request_controller.rb
@@ -278,7 +278,7 @@ class AdminRequestController < AdminController
if params[:incoming_message_id]
incoming_message = IncomingMessage.find(params[:incoming_message_id])
- email = incoming_message.mail.from_addrs[0].address
+ email = incoming_message.from_address
name = incoming_message.safe_mail_from || info_request.public_body.name
else
email = info_request.public_body.request_email
@@ -313,12 +313,12 @@ class AdminRequestController < AdminController
@raw_email = RawEmail.find(params[:id])
# 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.nil? && @raw_email.incoming_message.mail.from_addrs.size > 0)
+ if (@raw_email.incoming_message.info_request == InfoRequest.holding_pen_request && !@raw_email.incoming_message.empty_from_field?)
@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
+ email = @raw_email.incoming_message.from_email
domain = PublicBody.extract_domain_from_email(email)
if domain.nil?
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index 0cde238cd..3ba636e29 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -226,12 +226,6 @@ class GeneralController < ApplicationController
redirect_to request_url(info_request)
end
- # For debugging
- def fai_test
- sleep 10
- render :text => "awake\n"
- end
-
def custom_css
long_cache
@locale = self.locale_from_params()
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 60828e179..5205d0a2d 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -85,6 +85,28 @@ class IncomingMessage < ActiveRecord::Base
@mail
end
+ def from_address
+ self.mail.from_addrs[0].address
+ end
+
+ def empty_from_field?
+ self.mail.from_addrs.nil? || self.mail.from_addrs.size == 0
+ end
+
+ def from_email
+ self.mail.from_addrs[0].spec
+ end
+
+ def addresses
+ ((self.mail.to || []) +
+ (self.mail.cc || []) +
+ (self.mail.envelope_to || [])).uniq
+ end
+
+ def message_id
+ self.mail.message_id
+ end
+
# Returns the name of the person the incoming message is from, or nil if
# there isn't one or if there is only an email address. XXX can probably
# remove from_name_if_present (which is a monkey patch) by just calling
@@ -93,10 +115,10 @@ class IncomingMessage < ActiveRecord::Base
# Return false if for some reason this is a message that we shouldn't let them reply to
def _calculate_valid_to_reply_to
# check validity of email
- if self.mail.from_addrs.nil? || self.mail.from_addrs.size == 0
+ if empty_from_field?
return false
end
- email = self.mail.from_addrs[0].spec
+ email = self.from_email
if !MySociety::Validate.is_valid_email(email)
return false
end
@@ -136,7 +158,7 @@ class IncomingMessage < ActiveRecord::Base
# instead?
self.mail_from = self.mail.from_name_if_present
begin
- self.mail_from_domain = PublicBody.extract_domain_from_email(self.mail.from_addrs[0].spec)
+ self.mail_from_domain = PublicBody.extract_domain_from_email(self.from_email)
rescue NoMethodError
self.mail_from_domain = ""
end
@@ -1062,10 +1084,10 @@ class IncomingMessage < ActiveRecord::Base
# Return false if for some reason this is a message that we shouldn't let them reply to
def valid_to_reply_to?
# check validity of email
- if self.mail.from_addrs.nil? || self.mail.from_addrs.size == 0
+ if empty_from_field?
return false
end
- email = self.mail.from_addrs[0].spec
+ email = self.from_email
if !MySociety::Validate.is_valid_email(email)
return false
end
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 89893a396..e9335228a 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -355,12 +355,7 @@ public
def InfoRequest.guess_by_incoming_email(incoming_message)
guesses = []
# 1. Try to guess based on the email address(es)
- addresses =
- (incoming_message.mail.to || []) +
- (incoming_message.mail.cc || []) +
- (incoming_message.mail.envelope_to || [])
- addresses.uniq!
- for address in addresses
+ incoming_message.addresses.each do |address|
id, hash = InfoRequest._extract_id_hash_from_email(address)
guesses.push(InfoRequest.find_by_id(id))
guesses.push(InfoRequest.find_by_idhash(hash))
@@ -419,8 +414,7 @@ public
end
for im in self.incoming_messages
- other_message_id = im.mail.message_id
- if message_id == other_message_id
+ if message_id == im.message_id
return true
end
end
@@ -1130,7 +1124,11 @@ public
}
if deep
- ret[:user] = self.user.json_for_api
+ if self.user
+ ret[:user] = self.user.json_for_api
+ else
+ ret[:user_name] = self.user_name
+ end
ret[:public_body] = self.public_body.json_for_api
ret[:info_request_events] = self.info_request_events.map { |e| e.json_for_api(false) }
end
diff --git a/app/models/outgoing_mailer.rb b/app/models/outgoing_mailer.rb
index a307bb778..277794c69 100644
--- a/app/models/outgoing_mailer.rb
+++ b/app/models/outgoing_mailer.rb
@@ -47,7 +47,7 @@ class OutgoingMailer < ApplicationMailer
return info_request.recipient_name_and_email
else
# calling safe_mail_from from so censor rules are run
- return TMail::Address.address_from_name_and_email(incoming_message_followup.safe_mail_from, incoming_message_followup.mail.from_addrs[0].spec).to_s
+ return TMail::Address.address_from_name_and_email(incoming_message_followup.safe_mail_from, incoming_message_followup.from_email).to_s
end
end
# Used in the preview of followup
@@ -64,7 +64,7 @@ class OutgoingMailer < ApplicationMailer
if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to?
return info_request.recipient_email
else
- return incoming_message_followup.mail.from_addrs[0].spec
+ return incoming_message_followup.from_email
end
end
# Subject to use for followup
diff --git a/app/views/comment/_single_comment.rhtml b/app/views/comment/_single_comment.rhtml
index 013e5e107..b645721cf 100644
--- a/app/views/comment/_single_comment.rhtml
+++ b/app/views/comment/_single_comment.rhtml
@@ -11,7 +11,7 @@
</h2>
<div class="comment_in_request_text">
<p>
- <img class="comment_quote" src="/images/quote.png" alt="">
+ <img class="comment_quote" src="/images/quote-marks.png" alt="">
<%= comment.get_body_for_html_display %>
</p>
</div>
diff --git a/app/views/request/_correspondence.rhtml b/app/views/request/_correspondence.rhtml
index bcfc93657..99c6c7d26 100644
--- a/app/views/request/_correspondence.rhtml
+++ b/app/views/request/_correspondence.rhtml
@@ -1,5 +1,5 @@
<div class="ff-print-fix"></div>
-<%
+<%
if !info_request_event.nil? && info_request_event.event_type == 'response'
incoming_message = info_request_event.incoming_message
end
@@ -21,9 +21,9 @@ if not incoming_message.nil?
<p class="event_actions">
<% if !@user.nil? && @user.admin_page_links? %>
- <%= link_to "Admin", admin_url("request/show_raw_email/" + incoming_message.raw_email_id.to_s) %> |
+ <%= link_to "Admin", admin_url("request/show_raw_email/" + incoming_message.raw_email_id.to_s) %> |
<% end %>
- <%= link_to _("Link to this"), incoming_message_url(incoming_message), :class => "link_to_this" %>
+ <%= link_to _("Link to this"), incoming_message_url(incoming_message), :class => "link_to_this" %>
</p>
</div>
<%
@@ -39,28 +39,28 @@ elsif [ 'sent', 'followup_sent' ].include?(info_request_event.event_type)
<%= render :partial => 'bubble', :locals => { :body => outgoing_message.get_body_for_html_display(), :attachments => nil } %>
- <p class="event_actions">
+ <p class="event_actions">
<% if outgoing_message.status == 'ready' && !@info_request.is_external? %>
<strong>Warning:</strong> This message has <strong>not yet been sent</strong> for an unknown reason.
- <% end %>
+ <% end %>
<!-- Can use this to get name of who followup was too, if say you
play with proper from display, but not sure needed
<% if outgoing_message.message_type == 'followup' && !outgoing_message.incoming_message_followup.nil? && !outgoing_message.incoming_message_followup.safe_mail_from.nil? %>
- Follow up sent to: <%=h outgoing_message.incoming_message_followup.safe_mail_from %>
- <% end %>
+ Follow up sent to: <%=h outgoing_message.incoming_message_followup.safe_mail_from %>
+ <% end %>
-->
- <%= link_to _("Link to this"), outgoing_message_url(outgoing_message), :class => "link_to_this" %>
+ <%= link_to _("Link to this"), outgoing_message_url(outgoing_message), :class => "link_to_this" %>
</p>
</div>
<% elsif [ 'resent', 'followup_resent' ].include?(info_request_event.event_type) %>
- <div class="outgoing correspondence" id="outgoing-<%=outgoing_message.id.to_s%>">
+ <div class="outgoing correspondence" id="outgoing-<%=info_request_event.outgoing_message.id.to_s%>">
<h2>
<%= simple_date(info_request_event.created_at) %>
</h2>
- <p class="event_plain">
- Sent
+ <p class="event_plain">
+ Sent
<% if info_request_event.outgoing_message.message_type == 'initial_request' %>
request
<% elsif info_request_event.outgoing_message.message_type == 'followup' %>
@@ -72,7 +72,7 @@ elsif [ 'sent', 'followup_sent' ].include?(info_request_event.event_type)
to <%= public_body_link(@info_request.public_body) %> again<% if not info_request_event.same_email_as_previous_send? %>, using a new contact address<% end %>.
</p>
</div>
-<% elsif info_request_event.event_type == 'comment'
+<% elsif info_request_event.event_type == 'comment'
comment = info_request_event.comment
%>
<%= render :partial => 'comment/single_comment', :locals => { :comment => comment } %>
diff --git a/app/views/user/_show_user_info.rhtml b/app/views/user/_show_user_info.rhtml
index 5dfecee1e..3c229e9ce 100644
--- a/app/views/user/_show_user_info.rhtml
+++ b/app/views/user/_show_user_info.rhtml
@@ -1,7 +1,7 @@
<% if !@display_user.get_about_me_for_html_display.empty? || @is_you %>
<div class="user_about_me">
- <img class="comment_quote" src="/images/quote.png" alt="">
+ <img class="comment_quote" src="/images/quote-marks.png" alt="">
<%= @display_user.get_about_me_for_html_display %>
<% if @is_you %>
(<%= link_to _("edit text about you"), set_profile_about_me_url() %>)